天津投入产出系统后端
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.
 
 
 
 
 
 

858 lines
25 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QMAPP.FJC.Entity.ProduceManage;
using QMAPP.ServicesAgent;
using QMAPP.FJC.Entity.Operation;
using QMAPP.KB.Entity;
using QMAPP.FJC.Entity;
using QMFrameWork.Data;
using System.Threading;
using QMAPP.WinForm.Common;
namespace QMAPP.WinForm.Forms.Mend
{
public partial class SpecifyNewForm : Form
{
Product product = new Product();
bool isValid = false;
public List<DefectType> getSelectList = new List<DefectType>();
List<DefectType> defectTypeList = new List<DefectType>();
BarCodeHook BarCode = new BarCodeHook();
public static SynchronizationContext SynchContext;
void BarCode_BarCodeEvent(BarCodeHook.BarCodes barCode)
{
ShowInfo(barCode);
}
public SpecifyNewForm()
{
InitializeComponent();
SynchContext = new SynchronizationContext();
BarCode.BarCodeEvent += new BarCodeHook.BarCodeDelegate(BarCode_BarCodeEvent);
BarCode.Start();
rA.Checked = false;
rB.Checked = false;
rC.Checked = false;
}
public SpecifyNewForm(string pid)
{
InitializeComponent();
tsbSave.Visible = false;
ShowDetail(pid);
txtCode.Enabled = false;
}
private void ShowInfo(BarCodeHook.BarCodes barCode)
{
if (!this.txtCode.Focused)
{
this.txtCode.Focus();
}
}
private void SpecifyNewForm_Load(object sender, EventArgs e)
{
DGMendRecorder.AutoGenerateColumns = false;
}
private void ShowDetail(string pid)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
MendRecorder mendRecorder = agent.InvokeServiceFunction<MendRecorder>(B9IPCService.MendRecorderBLL_GetMendRecorderInfo.ToString(), new MendRecorder() { PID = pid });
txtCode.Text = mendRecorder.PRODUCTCODE;
if (mendRecorder.MENDRESULT == "0")
{
rbMend.Checked = true;
}
else
{
rbScarp.Checked = true;
}
foreach(MenderReason o in mendRecorder.reasonList)
{
defectTypeList.Add(
new DefectType(){
DEFECTKEY=o.DEFECTKEY,
DEFECTVALUE=o.DEFECTVALUE,
POSITION=o.POSITION
});
}
if (mendRecorder.PRODUCESHIFTTCODE == "A")
{
rA.Checked = true;
}
else if (mendRecorder.PRODUCESHIFTTCODE == "B")
{
rB.Checked = true;
}
else
{
rC.Checked = true;
}
//comIndex.Text = mendRecorder.PRODUCESHIFTTCODE;
GridBind(defectTypeList);
ShowPicture(defectTypeList);
}
private void GridBind(List<DefectType> defectTypeList)
{
DGMendRecorder.DataSource = defectTypeList;
}
private void PictureBoxDeal(Image unSelectImage,Image selectImage ,object sender )
{
//tsbSave.Visible == false是查看明细
if (tsbSave.Visible == false)
{
return;
}
PictureBox pb = (PictureBox)sender;
string postion = pb.Name.Substring(2);
if (defectTypeList.Count(o => o.POSITION == postion) > 0)
{
pb.Image = unSelectImage;
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;
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);
txtCode.Focus();
}
#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();
}
private void txtCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)//如果输入的是回车键
{
var scode = txtCode.Text.Trim().ToUpper();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<Product> result = agent.InvokeServiceFunction<DataResult<Product>>("MendRecorderBLL_CheckProductCodeNew", scode);
if (result.IsSuccess == true)
{
product = result.Result;
lblError.Text = product.PRODUCTTYPENAME + scode + " " + "当前工序:" + product.CURRENTPROCESSNAME + " " + "状态:" + product.STATUSNAME;
//lblError.Text = product.PRODUCTTYPENAME + product.PRODUCTCODE + " " + "当前工序:" + product.CURRENTPROCESSNAME + " " + "状态:" + product.STATUSNAME;
this.lblError.ForeColor = Color.Black;
isValid = true;
}
else
{
lblError.Text = result.Msg ;
this.lblError.ForeColor = Color.Red;
isValid = false;
}
txtCode.Text = "";
}
}
private void tsbSave_Click(object sender, EventArgs e)
{
if (isValid == false)
{
MessageBox.Show("请扫描正确的条码信息!", "提示");
return;
}
if (defectTypeList.Count == 0)
{
MessageBox.Show("请选择缺陷类型!", "提示");
return;
}
if (product.STATUS == EnumGeter.STATUS.SCRAP.GetHashCode().ToString() && rbScarp.Checked == true)
{
MessageBox.Show("该产品已经报废!", "提示");
return;
}
product.STATUS = (rbScarp.Checked) ? EnumGeter.STATUS.SCRAP.GetHashCode().ToString() : EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
//product.PRODUCESHIFTTCODE = comIndex.Text;
if (rA.Checked)
{
product.PRODUCESHIFTTCODE = "A";
}
else if (rB.Checked)
{
product.PRODUCESHIFTTCODE = "B";
}
else
{
product.PRODUCESHIFTTCODE = "C";
}
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<int> result = agent.InvokeServiceFunction<DataResult<int>>("MendRecorderBLL_InsertMendRecordItemNew", product, defectTypeList);
if (result.IsSuccess == true)
{
InitForm();
txtCode.Focus();
}
else
{
MessageBox.Show(result.Msg, "提示");
return;
}
}
/// <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.Image = QMAPP.WinForm.Resource1._1A_select;
//}
//if (list.Contains("1B"))
//{
// pB1B.Image = QMAPP.WinForm.Resource1._1B_select;
//}
//if (list.Contains("1C"))
//{
// pB1C.Image = QMAPP.WinForm.Resource1._1C_select;
//}
//if (list.Contains("1D"))
//{
// pB1D.Image = QMAPP.WinForm.Resource1._1D_select;
//}
//if (list.Contains("1E"))
//{
// pB1E.Image = QMAPP.WinForm.Resource1._1E_select;
//}
//if (list.Contains("1F"))
//{
// pB1F.Image = QMAPP.WinForm.Resource1._1F_select;
//}
//if (list.Contains("2A"))
//{
// pB2A.Image = QMAPP.WinForm.Resource1._2A_select;
//}
//if (list.Contains("2B"))
//{
// pB2B.Image = QMAPP.WinForm.Resource1._2B_select;
//}
//if (list.Contains("2C"))
//{
// pB2C.Image = QMAPP.WinForm.Resource1._2C_select;
//}
//if (list.Contains("2D"))
//{
// pB2D.Image = QMAPP.WinForm.Resource1._2D_select;
//}
//if (list.Contains("2E"))
//{
// pB2E.Image = QMAPP.WinForm.Resource1._2E_select;
//}
//if (list.Contains("2F"))
//{
// pB2F.Image = QMAPP.WinForm.Resource1._2F_select;
//}
//if (list.Contains("3A"))
//{
// pB3A.Image = QMAPP.WinForm.Resource1._3A_select;
//}
//if (list.Contains("3B"))
//{
// pB3B.Image = QMAPP.WinForm.Resource1._3B_select;
//}
//if (list.Contains("3C"))
//{
// pB3C.Image = QMAPP.WinForm.Resource1._3C_select;
//}
//if (list.Contains("3D"))
//{
// pB3D.Image = QMAPP.WinForm.Resource1._3D_select;
//}
//if (list.Contains("3E"))
//{
// pB3E.Image = QMAPP.WinForm.Resource1._3E_select;
//}
//if (list.Contains("3F"))
//{
// pB3F.Image = QMAPP.WinForm.Resource1._3F_select;
//}
//if (list.Contains("4A"))
//{
// pB4A.Image = QMAPP.WinForm.Resource1._4A_select;
//}
//if (list.Contains("4B"))
//{
// pB4B.Image = QMAPP.WinForm.Resource1._4B_select;
//}
//if (list.Contains("4C"))
//{
// pB4C.Image = QMAPP.WinForm.Resource1._4C_select;
//}
//if (list.Contains("4D"))
//{
// pB4D.Image = QMAPP.WinForm.Resource1._4D_select;
//}
//if (list.Contains("4E"))
//{
// pB4E.Image = QMAPP.WinForm.Resource1._4E_select;
//}
//if (list.Contains("4F"))
//{
// pB4F.Image = QMAPP.WinForm.Resource1._4F_select;
//}
//if (list.Contains("5A"))
//{
// pB5A.Image = QMAPP.WinForm.Resource1._5A_select;
//}
//if (list.Contains("5B"))
//{
// pB5B.Image = QMAPP.WinForm.Resource1._5B_select;
//}
//if (list.Contains("5C"))
//{
// pB5C.Image = QMAPP.WinForm.Resource1._5C_select;
//}
//if (list.Contains("5D"))
//{
// pB5D.Image = QMAPP.WinForm.Resource1._5D_select;
//}
//if (list.Contains("5E"))
//{
// pB5E.Image = QMAPP.WinForm.Resource1._5E_select;
//}
//if (list.Contains("5F"))
//{
// pB5F.Image = QMAPP.WinForm.Resource1._5F_select;
//}
//if (list.Contains("6C"))
//{
// pB6C.Image = QMAPP.WinForm.Resource1._6C_select;
//}
//if (list.Contains("6D"))
//{
// pB6D.Image = QMAPP.WinForm.Resource1._6D_select;
//}
//if (list.Contains("6E"))
//{
// pB6E.Image = QMAPP.WinForm.Resource1._6E_select;
//}
}
private void InitForm()
{
#region 刷新图片
//pB1A.Image = QMAPP.WinForm.Resource1._1A;
//pB1B.Image = QMAPP.WinForm.Resource1._1B;
//pB1C.Image = QMAPP.WinForm.Resource1._1C;
//pB1D.Image = QMAPP.WinForm.Resource1._1D;
//pB1E.Image = QMAPP.WinForm.Resource1._1E;
//pB1F.Image = QMAPP.WinForm.Resource1._1F;
//pB2A.Image = QMAPP.WinForm.Resource1._2A;
//pB2B.Image = QMAPP.WinForm.Resource1._2B;
//pB2C.Image = QMAPP.WinForm.Resource1._2C;
//pB2D.Image = QMAPP.WinForm.Resource1._2D;
//pB2E.Image = QMAPP.WinForm.Resource1._2E;
//pB2F.Image = QMAPP.WinForm.Resource1._2F;
//pB3A.Image = QMAPP.WinForm.Resource1._3A;
//pB3B.Image = QMAPP.WinForm.Resource1._3B;
//pB3C.Image = QMAPP.WinForm.Resource1._3C;
//pB3D.Image = QMAPP.WinForm.Resource1._3D;
//pB3E.Image = QMAPP.WinForm.Resource1._3E;
//pB3F.Image = QMAPP.WinForm.Resource1._3F;
//pB4A.Image = QMAPP.WinForm.Resource1._4A;
//pB4B.Image = QMAPP.WinForm.Resource1._4B;
//pB4C.Image = QMAPP.WinForm.Resource1._4C;
//pB4D.Image = QMAPP.WinForm.Resource1._4D;
//pB4E.Image = QMAPP.WinForm.Resource1._4E;
//pB4F.Image = QMAPP.WinForm.Resource1._4F;
//pB5A.Image = QMAPP.WinForm.Resource1._5A;
//pB5B.Image = QMAPP.WinForm.Resource1._5B;
//pB5C.Image = QMAPP.WinForm.Resource1._5C;
//pB5D.Image = QMAPP.WinForm.Resource1._5D;
//pB5E.Image = QMAPP.WinForm.Resource1._5E;
//pB5F.Image = QMAPP.WinForm.Resource1._5F;
//pB6C.Image = QMAPP.WinForm.Resource1._6C;
//pB6D.Image = QMAPP.WinForm.Resource1._6D;
//pB6E.Image = QMAPP.WinForm.Resource1._6E;
#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 rbMend_CheckedChanged(object sender, EventArgs e)
{
if (rbMend.Checked)
{
txtCode.Focus();
}
}
private void rbScarp_CheckedChanged(object sender, EventArgs e)
{
if (rbScarp.Checked)
{
txtCode.Focus();
}
}
private void rA_CheckedChanged(object sender, EventArgs e)
{
if (rA.Checked)
{
txtCode.Focus();
}
}
private void rB_CheckedChanged(object sender, EventArgs e)
{
if (rB.Checked)
{
txtCode.Focus();
}
}
private void rC_CheckedChanged(object sender, EventArgs e)
{
if (rC.Checked)
{
txtCode.Focus();
}
}
}
}