天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1228 lines
40 KiB

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using QMAPP.FJC.Entity.ProduceManage;
using QMAPP.ServicesAgent;
using QMAPP.FJC.Entity.Operation;
using QMAPP.KB.Entity;
using System.Threading;
using QMAPP.FJC.Entity;
using QMAPP.WinForm.Common;
using QMAPP.WinForm.Forms.Operation;
using System.IO;
using QMAPP.MD.Entity;
using System.Net;
using System.Data;
namespace QMAPP.WinForm.Forms.Mend
{
public partial class MendRecorderReasonForm : Form
{
Product product = new Product();
SpecifyForm specifyForm=null;
MendRecorderWasteForm mendRecorderWasteForm = null;
OperationForm operationForm = null;
//获取服务代理
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
bool isValid = false;
public List<DefectType> getSelectList = new List<DefectType>();
List<DefectType> defectTypeList = new List<DefectType>();
BarCodeHook BarCode = new BarCodeHook();
public static SynchronizationContext SynchContext;
string productCode = "";
//public string materialType;
//private string ym = "";
DataTable defectTable = new DataTable();
void BarCode_BarCodeEvent(BarCodeHook.BarCodes barCode)
{
ShowInfo(barCode);
}
public MendRecorderReasonForm()
{
InitializeComponent();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
defectTable = agent.InvokeServiceFunction<DataTable>(B9IPCService.DefectTypeBLL_GetDefectType.ToString());
txtBarcode.Focus();
}
//新增一条报废记录
public MendRecorderReasonForm(SpecifyForm Mform, string materialType)
{
InitializeComponent();
SynchContext = new SynchronizationContext();
BarCode.BarCodeEvent += new BarCodeHook.BarCodeDelegate(BarCode_BarCodeEvent);
BarCode.Start();
this.specifyForm = Mform;
selectBackgroundImage(materialType);
//comTestBind();
}
//批量新增
public MendRecorderReasonForm(MendRecorderWasteForm Mform, string workcenter):this()
{
//InitializeComponent();
SynchContext = new SynchronizationContext();
BarCode.BarCodeEvent += new BarCodeHook.BarCodeDelegate(BarCode_BarCodeEvent);
BarCode.Start();
txtBarcode.Enabled = false;
this.mendRecorderWasteForm = Mform;
LoadDefectList(workcenter);
//comTestBind();
}
//加工操作--新增一条报废记录
public MendRecorderReasonForm(OperationForm Mform, string scode)
{
InitializeComponent();
getProduct(scode);
this.operationForm = Mform;
//selectBackgroundImage(product.MATERIAL_TYPE);
//comTestBind();
}
public MendRecorderReasonForm(string productCode):this()
{
//InitializeComponent();
this.productCode = productCode;
product.PRODUCTCODE = productCode;
product = agent.InvokeServiceFunction<Product>("ProductBLL_GetByCondition", product);
//selectBackgroundImage(product.MATERIAL_CODE);
//selectBackgroundImage(product.MATERIAL_TYPE);
txtBarcode.Text = product.PRODUCTCODE;
txtBarcode.Enabled = false;
tscbResult.Visible = tslResultTitle.Visible = false;
tslMessage.Text = string.Format("物料号:{0},物料名:{1}", product.MATERIAL_CODE, product.MATERIAL_NAME);
LoadDefectList(product.WORKCENTER_CODE);
}
private void LoadDefectList(string workcentercode)
{
//工作中心下属的缺陷类型
var defects = from row in defectTable.AsEnumerable()
where string.Equals(row["TYPE_CODE"], "") || string.Equals(row["TYPE_CODE"], workcentercode)
orderby row["DEFECTKEY"] ascending
select new Defect { Key = "" + row["DEFECTKEY"], Description = "" + row["DEFECTVALUE"] };
///查找缺陷代码以“-”为结尾的顶级缺陷项
var topleveldefects = from defect in defects
where defect.Key.EndsWith("-")
select defect;
flpList.Controls.Clear();
if (topleveldefects.Count() <= 0)
{
foreach (var defect in defects)
{
var checkbox = new CheckBox();
checkbox.Appearance = Appearance.Button;
checkbox.TextAlign = ContentAlignment.MiddleCenter;
checkbox.Height = 50;
checkbox.AutoSize = true;
checkbox.MinimumSize = new System.Drawing.Size { Height = 50 };
checkbox.Text = defect.Key + "/" + defect.Description;
checkbox.Tag = defect;
checkbox.CheckedChanged += new EventHandler(checkbox_CheckedChanged);
flpList.Controls.Add(checkbox);
}
}
else
{
///查找缺陷代码以“-”为开头的二级缺陷项
SubDefects = (from defect in defects
where defect.Key.StartsWith("-")
select defect).ToList();
foreach (var defect in topleveldefects)
{
var btn = new Button();
btn.TextAlign = ContentAlignment.MiddleCenter;
btn.Height = 50;
btn.AutoSize = true;
btn.MinimumSize = new System.Drawing.Size { Height = 50 };
btn.Text = defect.Key.Trim('-') + "/" + defect.Description;
btn.Tag = defect;
btn.Click += new EventHandler(btn_Click);
flpList.Controls.Add(btn);
}
}
}
void btn_Click(object sender, EventArgs e)
{
var btn = sender as Button;
var topdefect = btn.Tag as Defect;
var frmSubDefects = new MendReasonSubDefects(topdefect, SubDefects);
frmSubDefects.ShowDialog();
if (topdefect.SubDefects.Count > 0)
{
btn.Text = topdefect.Key.Trim('-') + "/" + topdefect.Description + "(" + topdefect.SubDefects.Count + ")";
btn.BackColor = Color.Orange;
}
else
{
btn.Text = topdefect.Key.Trim('-') + "/" + topdefect.Description ;
btn.BackColor = SystemColors.Control;
btn.UseVisualStyleBackColor = true;
}
}
void checkbox_CheckedChanged(object sender, EventArgs e)
{
var checkbox = sender as CheckBox;
if (checkbox.Checked)
{
checkbox.BackColor = Color.Orange;
}
else
{
checkbox.BackColor = SystemColors.Control;
checkbox.UseVisualStyleBackColor = true;
}
}
//明细进入
public MendRecorderReasonForm(string pid,string materialCode)
{
InitializeComponent();
tsbSave.Visible = false;
//comTestBind();
//comWorkCellBind("");
//判断零件号,选择不同图片
selectBackgroundImage(materialCode);
ShowDetail(pid);
}
private void ShowInfo(BarCodeHook.BarCodes barCode)
{
}
private void MendRecorderReasonForm_Load(object sender, EventArgs e)
{
tscbResult.SelectedIndex = 0;
if (txtBarcode.Enabled)
{
txtBarcode.Focus();
}
}
private void ShowDetail(string pid)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
MendRecorder mendRecorder = agent.InvokeServiceFunction<MendRecorder>(B9IPCService.MendRecorderBLL_GetMendRecorderInfo.ToString(), new MendRecorder() { PID = pid });
foreach(MenderReason o in mendRecorder.reasonList)
{
defectTypeList.Add(
new DefectType(){
DEFECTKEY=o.DEFECTKEY,
DEFECTVALUE=o.DEFECTVALUE,
POSITION=o.POSITION
});
}
GridBind(defectTypeList);
ShowPicture(defectTypeList);
}
private void GridBind(List<DefectType> defectTypeList)
{
//DGMendRecorder.DataSource = defectTypeList;
}
private void PictureBoxDeal(Image unSelectImage,Image selectImage ,object sender )
{
PictureBox pb = (PictureBox)sender;
string postion = pb.Name.Substring(2);
if (defectTypeList.Count(o => o.POSITION == postion) > 0)
{
//pb.Image = unSelectImage;
pb.BackgroundImage = null;
List<DefectType> list = defectTypeList
.Where(o => o.POSITION != postion).OrderBy(o => o.POSITION)
.ToList<DefectType>();
defectTypeList = list;
}
else
{
ItemForm itemform = new ItemForm(this);
itemform.ShowDialog();
if (getSelectList.Count > 0)
{
//pb.Image = selectImage;
pb.BackgroundImage = QMAPP.WinForm.Resource1.ok; ;
foreach (var dt in getSelectList)
{
dt.POSITION = postion;
defectTypeList.Add(dt);
}
defectTypeList = defectTypeList
.OrderBy(o => o.POSITION)
.ToList<DefectType>();
getSelectList = new List<DefectType>();
}
}
GridBind(defectTypeList);
}
#region 双击事件
private void pB1A_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._1A;
Image selectImage = QMAPP.WinForm.Resource1._1A_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB1B_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._1B;
Image selectImage = QMAPP.WinForm.Resource1._1B_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB1C_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._1C;
Image selectImage = QMAPP.WinForm.Resource1._1C_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB1D_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._1D;
Image selectImage = QMAPP.WinForm.Resource1._1D_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB1E_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._1E;
Image selectImage = QMAPP.WinForm.Resource1._1E_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB1F_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._1F;
Image selectImage = QMAPP.WinForm.Resource1._1F_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB2A_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._2A;
Image selectImage = QMAPP.WinForm.Resource1._2A_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB2B_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._2B;
Image selectImage = QMAPP.WinForm.Resource1._2B_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB2C_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._2C;
Image selectImage = QMAPP.WinForm.Resource1._2C_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB2D_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._2D;
Image selectImage = QMAPP.WinForm.Resource1._2D_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB2E_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._2E;
Image selectImage = QMAPP.WinForm.Resource1._2E_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB2F_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._2F;
Image selectImage = QMAPP.WinForm.Resource1._2F_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB3A_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._3A;
Image selectImage = QMAPP.WinForm.Resource1._3A_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB3B_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._3B;
Image selectImage = QMAPP.WinForm.Resource1._3B_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB3C_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._3C;
Image selectImage = QMAPP.WinForm.Resource1._3C_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB3D_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._3D;
Image selectImage = QMAPP.WinForm.Resource1._3D_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB3E_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._3E;
Image selectImage = QMAPP.WinForm.Resource1._3E_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB3F_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._3F;
Image selectImage = QMAPP.WinForm.Resource1._3F_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB4A_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._4A;
Image selectImage = QMAPP.WinForm.Resource1._4A_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB4B_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._4B;
Image selectImage = QMAPP.WinForm.Resource1._4B_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB4C_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._4C;
Image selectImage = QMAPP.WinForm.Resource1._4C_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB4D_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._4D;
Image selectImage = QMAPP.WinForm.Resource1._4D_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB4E_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._4E;
Image selectImage = QMAPP.WinForm.Resource1._4E_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB4F_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._4F;
Image selectImage = QMAPP.WinForm.Resource1._4F_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB5A_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._5A;
Image selectImage = QMAPP.WinForm.Resource1._5A_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB5B_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._5B;
Image selectImage = QMAPP.WinForm.Resource1._5B_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB5C_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._5C;
Image selectImage = QMAPP.WinForm.Resource1._5C_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB5D_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._5D;
Image selectImage = QMAPP.WinForm.Resource1._5D_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB5E_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._5E;
Image selectImage = QMAPP.WinForm.Resource1._5E_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB5F_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._5F;
Image selectImage = QMAPP.WinForm.Resource1._5F_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB6A_DoubleClick(object sender, EventArgs e)
{
}
private void pB6B_DoubleClick(object sender, EventArgs e)
{
}
private void pB6C_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._6C;
Image selectImage = QMAPP.WinForm.Resource1._6C_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB6D_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._6D;
Image selectImage = QMAPP.WinForm.Resource1._6D_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB6E_DoubleClick(object sender, EventArgs e)
{
Image unSelectImage = QMAPP.WinForm.Resource1._6E;
Image selectImage = QMAPP.WinForm.Resource1._6E_select;
PictureBoxDeal(unSelectImage, selectImage, sender);
}
private void pB6F_DoubleClick(object sender, EventArgs e)
{
}
#endregion
private void tsbClose_Click(object sender, EventArgs e)
{
this.Close();
}
//判断零件号,选择不同图片
/// <summary>
///
/// </summary>
/// <param name="materialTepy"></param>
private void selectBackgroundImage(string materialTepy)
{
#region 20190218郭兆福
//20190218郭兆福
//根据物料号去找图片名称
string picName = "";
BasicData basicData = new BasicData();
Material materialInfo = new Material();
materialInfo = basicData.GetMaterialInfo(materialTepy);
if (materialInfo.IMAGE_PATH != null)
{
picName = materialInfo.IMAGE_PATH;
}
else
{
//提示不存在此零件图片信息,返回不执行下面动作;
MessageBox.Show("不存在此零件图片信息!");
//flowLayoutPanel1.BackgroundImage = null;
return;
}
//先在Winform本地找文件,显示
string WinImagePath = System.Configuration.ConfigurationManager.AppSettings["WinImagePath"].ToString();
string ImagePath = System.Configuration.ConfigurationManager.AppSettings["ImagePath"].ToString();
if (!Directory.Exists(WinImagePath))
{
Directory.CreateDirectory(WinImagePath);
}
string picPath = WinImagePath + picName;
if (!File.Exists(picPath))
{
//找不到文件再去Md项目下载图片存至WinImagePath,并直接显示
WebClient client = new WebClient();
string serverPath = ImagePath + picName;
try
{
WebRequest myre = WebRequest.Create(serverPath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
try
{
client.DownloadFile(serverPath, picName);
FileStream fs = new FileStream(picName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
byte[] mbyte = r.ReadBytes((int)fs.Length);
FileStream fstr = new FileStream(picPath, FileMode.OpenOrCreate, FileAccess.Write);
fstr.Write(mbyte, 0, (int)fs.Length);
fstr.Close();
//flowLayoutPanel1.BackgroundImage = Image.FromFile(picPath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
else
{
//存在则直接显示图片
//flowLayoutPanel1.BackgroundImage = Image.FromFile(picPath);
}
#endregion
#region 20180131 周晓东增加零件号判断显示图片
////20180131 周晓东增加零件号判断显示图片
//if (materialTepy == "DP_ASSY_LF")
//{
// //门板左1
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.mbz1;
//}
//else if (materialTepy == "DP_ASSY_LR")
//{
// //门板左2
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.mbz2;
//}
//else if (materialTepy == "DP_ASSY_RF")
//{
// //门板右1
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.mby1;
//}
//else if (materialTepy == "DP_ASSY_RR")
//{
// //门板右2
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.mby2;
//}
//else if (materialTepy == "IP_ASSY")
//{
// //仪表板
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.ybb;
//}
//else if (materialTepy == "DP_ARMRESTASSY_LR" ||
// materialTepy == "DP_ARMRESTASSY_RF" ||
// materialTepy == "DP_ARMRESTASSY_RR" ||
// materialTepy == "DP_ARMRESTASSY_LF" )
//{
// //扶手
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.fs;
//}
//else if (materialTepy == "DP_HANDLECOVER_LR" ||
// materialTepy == "DP_HANDLECOVER_RF" ||
// materialTepy == "DP_HANDLECOVER_RR" ||
// materialTepy == "DP_HANDLECOVER_LF")
//{
// //拉手盖板
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.lsgb;
//}
//else if (materialTepy == "IP_CLUSTER_BEZEL" )
//{
// //帽檐内板
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.mznb;
//}
//else if (materialTepy == "IP_FGRILLE" )
//{
// //前格栅
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.qgs;
//}
//else if (materialTepy == "DP_UPPERFRAME_LF" ||
// materialTepy == "DP_UPPERFRAME_RF" ||
// materialTepy == "DP_UPPERFRAME_RR" ||
// materialTepy == "DP_UPPERFRAME_LR" )
//{
// //上框架
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.skj;
//}
//else if (materialTepy == "IP_UPPER_PART" )
//{
// //上体
// flowLayoutPanel1.BackgroundImage = null;
//}
//else if (materialTepy == "IP_UPPER_FRAME")
//{
// //上体骨架
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.stgj;
//}
//else if (materialTepy == "IP_LOWER_FRAME")
//{
// //下体
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.xt;
//}
//else if (materialTepy == "IP_RAIRDUCT")
//{
// //右风道
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.yfd;
//}
//else if (materialTepy == "DP_MAPPOCKET_RR" ||
// materialTepy == "DP_MAPPOCKET_LF" ||
// materialTepy == "DP_MAPPOCKET_LR" ||
// materialTepy == "DP_MAPPOCKET_RF" )
//{
// //地图袋
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.dtd;
//}
//else if (materialTepy == "DP_CENTERASSY_RF" ||
// materialTepy == "DP_CENTERASSY_LF" ||
// materialTepy == "DP_CENTERASSY_LR" ||
// materialTepy == "DP_CENTERASSY_RR")
//{
// //中部插件
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.zbcj;
//}
//else if (materialTepy == "IP_MID_COVER")
//{
// //中护板
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.zhb;
//}
//else if (materialTepy == "IP_ACAIRDUCT_ASSY")
//{
// //中央吹面风道
// flowLayoutPanel1.BackgroundImage = null;
//}
//else if (materialTepy == "IP_LAIRDUCT")
//{
// //左风道
// flowLayoutPanel1.BackgroundImage = QMAPP.WinForm.Resource1.zfd;
//}
//else if (materialTepy == "IP_LOWLCOVER_ASSY")
//{
// //左下护板
// flowLayoutPanel1.BackgroundImage = Resource1.zxhb;//.GetBitmap("zxhb");
//}
//else
//{
// flowLayoutPanel1.BackgroundImage = null;
//}
#endregion
}
private void tsbSave_Click(object sender, EventArgs e)
{
defectTypeList.Clear();
foreach (var cb in flpList.Controls)
{
var checkbox = cb as CheckBox;
if (checkbox != null && checkbox.Checked)
{
Defect defect = checkbox.Tag as Defect;
if (defect != null)
{
defectTypeList.Add(new DefectType
{
DEFECTKEY = defect.Key,
DEFECTVALUE = defect.Description,
POSITION = ""
});
}
}
else
{
var btn = cb as Button;
if (btn != null)
{
Defect defect = btn.Tag as Defect;
if (defect != null&&defect.SubDefects.Count>0)
{
foreach (var subdefect in defect.SubDefects)
{
defectTypeList.Add(new DefectType
{
DEFECTKEY = defect.Key + subdefect.Key.TrimStart('-'),
DEFECTVALUE = defect.Description + " " + subdefect.Description,
POSITION = ""
});
}
}
}
}
}
if (defectTypeList.Count == 0)
{
MessageBox.Show("请选择缺陷类型!", "提示");
return;
}
if (specifyForm != null) specifyForm.defectTypeList = defectTypeList;
if (mendRecorderWasteForm != null) mendRecorderWasteForm.defectTypeList = defectTypeList;
if (string.IsNullOrEmpty(productCode) == false)
{
product.BATCH_NO = product.CREATEDATE.ToString("yyyyMMdd");
if (!operationFormSave())
{
return;
}
product = null;
productCode = "";
flpList.Controls.Clear();
tslMessage.Text = "保存成功!";
txtBarcode.Text = "";
txtBarcode.Focus();
}
if (!txtBarcode.Enabled)
{
this.Close();
}
}
private void getProduct(string scode)
{
if (System.Text.RegularExpressions.Regex.IsMatch(scode, "^DP\\w+(-\\w+)?-DF[LR][FR]\\w+$"))//扫描输入为门板计划标签
{
//从计划标签中截取产品码
scode = scode.Substring(scode.LastIndexOf('-') + 1);
}
DataResult<Product> result =
agent.InvokeServiceFunction<DataResult<Product>>
("MendRecorderBLL_CheckProductCodeNew", scode);
if (result.IsSuccess == true)
{
product = result.Result;
MainOperation mainoperation = agent.InvokeServiceFunction<MainOperation>("MendRecorderBLL_GetMianOperationInfo", product.PID);
product.SHIFT_CODE = mainoperation.PRODUCESHIFTTCODE;
product.BATCH_NO = mainoperation.OPERATEDDATE.ToString("yyyyMMdd");
product.WORKCELL_CODE = mainoperation.WORKCELL_CODE;
product.WORKCENTER_CODE = mainoperation.WORKCENTER_CODE;
product.MACHINECODDE = mainoperation.MACHINECODDE;
}
else
{
MessageBox.Show("加工记录异常,无法返修。");
this.Close();
}
}
private bool operationFormSave()
{
if (tscbResult.SelectedIndex == 0)
{
product.STATUS = EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
}
else
{
product.STATUS = EnumGeter.STATUS.SCRAP.GetHashCode().ToString();
}
//是否测试件
product.MENDTEST = "否";
product.MENDNUMBER = 1;
DataResult<int> result = agent.InvokeServiceFunction<DataResult<int>>("MendRecorderBLL_InsertMendRecordItemNew", product, defectTypeList);
if (result.IsSuccess == true)
{
return true;
}
else
{
MessageBox.Show(result.Msg, "提示");
return false ;
}
}
/// <summary>
/// 设置图片显示
/// </summary>
/// <param name="defectTypeList"></param>
private void ShowPicture(List<DefectType> defectTypeList)
{
List<string> list = defectTypeList.Select(o => o.POSITION).Distinct().OrderBy(o=>o).ToList<string>();
//if (list.Contains("1A"))
//{
// pB1A.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("1B"))
//{
// pB1B.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("1C"))
//{
// pB1C.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("1D"))
//{
// pB1D.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("1E"))
//{
// pB1E.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("1F"))
//{
// pB1F.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("2A"))
//{
// pB2A.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("2B"))
//{
// pB2B.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("2C"))
//{
// pB2C.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("2D"))
//{
// pB2D.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("2E"))
//{
// pB2E.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("2F"))
//{
// pB2F.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("3A"))
//{
// pB3A.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("3B"))
//{
// pB3B.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("3C"))
//{
// pB3C.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("3D"))
//{
// pB3D.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("3E"))
//{
// pB3E.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("3F"))
//{
// pB3F.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("4A"))
//{
// pB4A.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("4B"))
//{
// pB4B.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("4C"))
//{
// pB4C.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("4D"))
//{
// pB4D.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("4E"))
//{
// pB4E.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("4F"))
//{
// pB4F.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("5A"))
//{
// pB5A.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("5B"))
//{
// pB5B.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("5C"))
//{
// pB5C.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("5D"))
//{
// pB5D.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("5E"))
//{
// pB5E.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("5F"))
//{
// pB5F.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("6C"))
//{
// pB6C.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("6D"))
//{
// pB6D.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
//if (list.Contains("6E"))
//{
// pB6E.BackgroundImage = QMAPP.WinForm.Resource1.ok;
//}
}
private void InitForm()
{
//#region 刷新图片
//pB1A.BackgroundImage = null;
//pB1B.BackgroundImage = null;
//pB1C.BackgroundImage = null;
//pB1D.BackgroundImage = null;
//pB1E.BackgroundImage = null;
//pB1F.BackgroundImage = null;
//pB2A.BackgroundImage = null;
//pB2B.BackgroundImage = null;
//pB2C.BackgroundImage = null;
//pB2D.BackgroundImage = null;
//pB2E.BackgroundImage = null;
//pB2F.BackgroundImage = null;
//pB3A.BackgroundImage = null;
//pB3B.BackgroundImage = null;
//pB3C.BackgroundImage = null;
//pB3D.BackgroundImage = null;
//pB3E.BackgroundImage = null;
//pB3F.BackgroundImage = null;
//pB4A.BackgroundImage = null;
//pB4B.BackgroundImage = null;
//pB4C.BackgroundImage = null;
//pB4D.BackgroundImage = null;
//pB4E.BackgroundImage = null;
//pB4F.BackgroundImage = null;
//pB5A.BackgroundImage = null;
//pB5B.BackgroundImage = null;
//pB5C.BackgroundImage = null;
//pB5D.BackgroundImage = null;
//pB5E.BackgroundImage = null;
//pB5F.BackgroundImage = null;
//pB6C.BackgroundImage = null;
//pB6D.BackgroundImage = null;
//pB6E.BackgroundImage = null;
//#endregion
product = new Product();
isValid = false;
getSelectList = new List<DefectType>();
defectTypeList = new List<DefectType>();
GridBind(defectTypeList);
//rbMend.Checked = true;
//lblError.Text = "保存成功!";
//txtCode.Focus();
}
private void pB3D_Click(object sender, EventArgs e)
{
}
private void tstxtBarcode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)//如果输入的是回车键
{
if(string.IsNullOrEmpty(txtBarcode.Text.Trim()))
{
tslMessage.Text = string.Format("请输入产品条码!");
txtBarcode.SelectAll();
txtBarcode.Focus();
return;
}
this.productCode = txtBarcode.Text.Trim();
var result = agent.InvokeServiceFunction<DataResult<Product>>("ProductBLL_GetProductInfoByAnyBarcode", this.productCode);
if(result.IsSuccess)
{
product=result.Result;
}
if (product == null || string.IsNullOrEmpty(product.PID))
{
tslMessage.Text = string.Format("此条码的产品信息未找到!");
txtBarcode.SelectAll();
txtBarcode.Focus();
return;
}
//selectBackgroundImage(product.MATERIAL_CODE);
//selectBackgroundImage(product.MATERIAL_TYPE);
tslMessage.Text = string.Format("物料号:{0},物料名:{1}", product.MATERIAL_CODE, product.MATERIAL_NAME);
LoadDefectList(product.WORKCENTER_CODE);
}
}
public List<Defect> SubDefects { get; set; }
}
}