using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using gregn6Lib; using Pub_Class; using System.Threading; using SQLHelper; namespace WorkM { public partial class MES_StationOutBill : Form { public MES_StationOutBill() { InitializeComponent(); } //下拉框 ComboBox cmb = new ComboBox();  //这里实例化一个ComboBox控件  Rectangle _Rectangle; //定义列 public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HEmpNoCol = 2; public const Int16 HEmpNumberCol = 3; public const Int16 HEmpNameCol = 4; public const Int16 HEntryIDCol = 5; public const Int16 HEmpIDCol = 6; public string ModName = "3791"; public string ModCaption = "完工汇报单"; public const string ModRightName = "MES_StationOutBill"; public const string ModRightNameEdit = ModRightName + "_Edit"; public const string ModRightNameDelete = ModRightName + "_Delete"; public bool BillChange; // public DBUtility.ClsPub.Enum_BillStatus BillStatus; public Int64 KeyID; public bool grdStatus; public DAL.ClsSc_StationOutBill BillNew = new DAL.ClsSc_StationOutBill(); public DAL.ClsSc_StationOutBill BillOld = new DAL.ClsSc_StationOutBill(); ClsGridViewSum oSumGrid = new ClsGridViewSum(); ClsGridViewSum oSumGrid_Sub = new ClsGridViewSum(); public Int64 lngBillKey; //流转卡ID public Int64 lngBillSubKey; //流转卡子ID long sHMainSourceInterID; //进站单ID string sHMainSourceBillNo; //进站单号 public string sIsMainLot; //是否主流转卡 public bool sIsIPQCCheck; //是否需要IPQC确认 //------------------------------------------------------------------------- #region 固定代码 //清空界面 public void Sub_ClearBill() { DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp); DBUtility.Xt_BaseBillFun.Sub_ClearBill1(tabPage2); DBUtility.Xt_BaseBillFun.Sub_ClearBill1(tabPage3); initGrid(); initGrid_Sub(); txtHBarCode.Text = ""; txtHProcExchBillNo.Enabled = true; txtHProcNo.Enabled = true; txtHBarCode.Enabled = true; tabControl2.SelectedIndex = 0; txtHSourceName.Focus(); //得到操作员信息(出站操作员默认为登录人,根据登录人用户名,找到职员同名的记录,默认写入 操作员 文本框;如果没找到则为空;) DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); Ds = oCn.RunProcReturn("select top 1 HItemID,HNumber,HName from Gy_Employee where HName= '" + ClsPub.CurUserName + "'", "Gy_Employee"); //写入信息 if (Ds == null || Ds.Tables[0].Rows.Count == 0) { txtHEmpID.Text = ""; txtHEmpID.Tag = 0; txtHEmpName.Text = ""; } else { txtHEmpID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HNumber"]); txtHEmpID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]); txtHEmpName.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HName"]); } txtHPersonNums.Text = "1"; txtHMachineNums.Text = "1"; } //出站按钮 private void cmdOK_Click(object sender, EventArgs e) { this.Sub_SaveBill(); DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "1"); cmdCancel.Focus(); } //取消按钮 private void cmdCancel_Click(object sender, EventArgs e) { if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_View) { //if (!BillOld.CheckHaveNoPass(BillOld.omodel.HInterID, ref ClsPub.sErrInfo)) //{ // MessageBox.Show(ClsPub.sErrInfo); // return; //} //if (txtHChecker.Text == "" && sIsMainLot == "是" && sIsIPQCCheck == true && BillOld.omodel.HInterID > 32798) //{ // MessageBox.Show("品质确认人不能为空!"); // return; //} } DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "1"); this.Close(); } //控件位置 private void Sub_ControlLocation() { //gbUp.Width = P1.Width - 20; //gbUp.Left = 10; //gbUp.Height = P1.Height - 35; //gbUp.Top = 30; } //窗体加载 private void Sc_StationOutBill_Load(object sender, EventArgs e) { //打印初始化 // oSumGrid_Sub.NoCol = HTagCol; oSumGrid_Sub.ogrdMain = grdSub; this.Text = ModCaption; this.lblCaption.Text = ModCaption; } //窗体尺寸变化时 private void Sc_StationOutBill_Resize(object sender, EventArgs e) { //Sub_ControlLocation(); } //timer private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; Sub_ControlLocation(); if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_View) { this.Sub_ShowBill(); } else { this.Sub_AddBill(); } } //窗体卸载 private void Sc_StationOutBill_FormClosing(object sender, FormClosingEventArgs e) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; //DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); DBUtility.Xt_BaseBillFun.SaveGrid(grdCardList, this.Name + "grdCardList"); } //新增单据 private void Sub_AddBill() { this.BillNew = new DAL.ClsSc_StationOutBill(); this.BillOld = new DAL.ClsSc_StationOutBill(); this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; this.Sub_OperStatus();//设置TOOLBAR this.Sub_ClearBill();//清空界面 this.txtHStationOutTime.Text = DBUtility.ClsPub.GetServerDate(-1); this.txtHBillNo.Text = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);//得到新单号 //txtHProcExchBillNo.Focus(); txtHBarCode.Focus(); } private void LotShow() { } //TOOLBAR状态 按钮是否灰度 public void Sub_OperStatus() { switch (BillStatus) { case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View: //浏览状态 grdStatus = false; cmdOK.Enabled = false; cmdBF.Enabled = true; cmdXG.Enabled = true; cmdCancel.Enabled = true; cmdChecker.Enabled = true; cmdBFChecker.Enabled = true; txtHBarCode.Enabled = false; Sub_LrtextStatus(false); break; case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew: //新增状态 grdStatus = true; cmdOK.Enabled = true; cmdBF.Enabled = false; cmdXG.Enabled = false; cmdCancel.Enabled = true; cmdChecker.Enabled = false; cmdBFChecker.Enabled = false; Sub_LrtextStatus(true); break; case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify: //修改状态 grdStatus = true; cmdOK.Enabled = true; cmdBF.Enabled = false; cmdXG.Enabled = false; cmdCancel.Enabled = true; cmdChecker.Enabled = false; cmdBFChecker.Enabled = false; Sub_LrtextStatus(true); break; } } //根据编辑状态 设置 控件是否允许录入 private void Sub_LrtextStatus(bool TextEnabled) { if (TextEnabled == true) { //控件全部有效 gbUp.Enabled = true; } else { //控件全部无效 gbUp.Enabled = false; } } #endregion #region 读写类 //显示单据 public void Sub_ShowBill() { DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();//物料 DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();//职员 DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();//生产资源 DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View();//工序 DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View();//班组 DAL.ClsGy_WorkCenter_View oCenter = new DAL.ClsGy_WorkCenter_View();//工作中心 //判断是否存在单据 if (BillOld.ShowBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == false) { MessageBox.Show(ClsPub.sExeReturnInfo, "提示"); return; } //获取是否需要IPQC确认信息 //if (BillOld.IPQCCheckByStationOut(BillOld.omodel.HInterID, ref sIsMainLot, ref sIsIPQCCheck, ref ClsPub.sExeReturnInfo) == false) //{ // MessageBox.Show(ClsPub.sExeReturnInfo, "提示"); // return; //} //清空 Sub_ClearBill(); //grid禁止刷新 //加载表头 if (oMater.GetInfoByID(BillOld.omodel.HMaterID)) { this.txtHMaterID.Text = oMater.omodel.HNumber; this.txtHMaterID.Tag = oMater.omodel.HItemID.ToString(); this.txtHMaterName.Text = oMater.omodel.HName; this.txtHMaterModel.Text = oMater.omodel.HModel; } else { this.txtHMaterID.Text = ""; this.txtHMaterName.Text = ""; this.txtHMaterModel.Text = ""; } // if (oCenter.GetInfoByID(BillOld.omodel.HCenterID)) { this.txtHCenterID.Text = oCenter.omodel.HName; this.txtHCenterID.Tag = oCenter.omodel.HItemID.ToString(); } else { this.txtHCenterID.Text = ""; } // if (oEmp.GetInfoByID(BillOld.omodel.HEmpID)) { this.txtHEmpID.Text = oEmp.omodel.HNumber; this.txtHEmpID.Tag = oEmp.omodel.HItemID.ToString(); this.txtHEmpName.Text = oEmp.omodel.HName; } else { this.txtHEmpID.Text = ""; } // if (oEmp.GetInfoByID(BillOld.omodel.HEmpID2)) { this.txtHEmpID2.Text = oEmp.omodel.HNumber; this.txtHEmpID2.Tag = oEmp.omodel.HItemID.ToString(); this.txtHEmpName2.Text = oEmp.omodel.HName; } else { this.txtHEmpID2.Text = ""; } // if (oEmp.GetInfoByID(BillOld.omodel.HEmpID3)) { this.txtHEmpID3.Text = oEmp.omodel.HNumber; this.txtHEmpID3.Tag = oEmp.omodel.HItemID.ToString(); this.txtHEmpName3.Text = oEmp.omodel.HName; } else { this.txtHEmpID3.Text = ""; } // if (oEmp.GetInfoByID(BillOld.omodel.HEmpID4)) { this.txtHEmpID4.Text = oEmp.omodel.HNumber; this.txtHEmpID4.Tag = oEmp.omodel.HItemID.ToString(); this.txtHEmpName4.Text = oEmp.omodel.HName; } else { this.txtHEmpID4.Text = ""; } // if (oEmp.GetInfoByID(BillOld.omodel.HEmpID5)) { this.txtHEmpID5.Text = oEmp.omodel.HNumber; this.txtHEmpID5.Tag = oEmp.omodel.HItemID.ToString(); this.txtHEmpName5.Text = oEmp.omodel.HName; } else { this.txtHEmpID5.Text = ""; } // if (oEmp.GetInfoByID(BillOld.omodel.HQCCheckID)) { this.txtHQCCheckID.Text = oEmp.omodel.HNumber; this.txtHQCCheckID.Tag = oEmp.omodel.HItemID.ToString(); this.txtHQCCheckName.Text = oEmp.omodel.HName; } else { this.txtHQCCheckID.Text = ""; } // if (oSource.GetInfoByID(BillOld.omodel.HSourceID)) { this.txtHSourceID.Text = oSource.omodel.HNumber; this.txtHSourceID.Tag = oSource.omodel.HItemID.ToString(); this.txtHSourceName.Text = oSource.omodel.HName; } else { this.txtHSourceID.Text = ""; this.txtHSourceName.Text = ""; } // if (oProc.GetInfoByID(BillOld.omodel.HProcID)) { this.txtHProcID.Text = oProc.omodel.HName; this.txtHProcID.Tag = oProc.omodel.HItemID.ToString(); } else { this.txtHProcID.Text = ""; } // if (oProc.GetInfoByID(BillOld.omodel.HPayProcID)) { this.txtHPayProcID.Text = oProc.omodel.HName; this.txtHPayProcID.Tag = oProc.omodel.HItemID.ToString(); } else { this.txtHPayProcID.Text = ""; } // if (oGroup.GetInfoByID(BillOld.omodel.HGroupID)) { this.txtHGroupID.Text = oGroup.omodel.HNumber; this.txtHGroupID.Tag = oGroup.omodel.HItemID.ToString(); this.txtHGroupName.Text = oGroup.omodel.HName; } else { this.txtHGroupID.Text = ""; this.txtHGroupName.Text = ""; } // this.txtHBillNo.Text = BillOld.omodel.HBillNo; this.txtHICMOBillNo.Text = BillOld.omodel.HICMOBillNo; this.txtHICMOBillNo.Tag = BillOld.omodel.HICMOInterID; lngBillKey = BillOld.omodel.HProcExchInterID; lngBillSubKey = BillOld.omodel.HProcExchEntryID; this.txtHProcExchBillNo.Text = BillOld.omodel.HProcExchBillNo; this.txtHStationOutTime.Text = BillOld.omodel.HStationOutTime.ToString(); this.txtHICMOQty.Text = BillOld.omodel.HICMOQty.ToString(); this.txtHPlanQty.Text = BillOld.omodel.HPlanQty.ToString(); this.txtHQty.Text = BillOld.omodel.HQty.ToString(); this.txtHDSQty.Text = BillOld.omodel.HDSQty.ToString(); this.txtHChongQty.Text = BillOld.omodel.HChongQty.ToString(); this.txtHPieceQty.Text = BillOld.omodel.HPieceQty.ToString(); this.txtHPlanPieceQty.Text = BillOld.omodel.HPlanPieceQty.ToString(); this.txtHBadCount.Text = BillOld.omodel.HBadCount.ToString(); this.txtHWasterQty.Text = BillOld.omodel.HWasterQty.ToString(); //this.txtHSourceName.Text = BillOld.omodel.HSourceName.ToString(); this.txtHBadPNL.Text = BillOld.omodel.HBadPNL.ToString(); this.txtHRemark.Text = BillOld.omodel.HRemark.ToString(); this.txtHProcNo.Text = BillOld.omodel.HProcNo.ToString(); this.txtHWorkTimes.Text = BillOld.omodel.HWorkTimes.ToString(); this.txtHOrderProcNO.Text = BillOld.omodel.HOrderProcNO.ToString(); this.chkHLastSubProc.Checked = BillOld.omodel.HLastSubProc; this.txtHPriceRate.Text = BillOld.omodel.HPriceRate.ToString(); sHMainSourceInterID = BillOld.omodel.HMainSourceInterID; sHMainSourceBillNo = BillOld.omodel.HMainSourceBillNo; this.txtHChecker.Text = BillOld.omodel.HChecker; this.txtHWorkTimes.Text = BillOld.omodel.HWorkTimes.ToString(); this.txtHMouldNum.Text = BillOld.omodel.HMouldNum.ToString(); this.txtHSourceNameList.Text = BillOld.omodel.HSourceNameList.ToString(); this.txtHPersonNums.Text = BillOld.omodel.HPersonNums.ToString(); this.txtHMachineNums.Text = BillOld.omodel.HMachineNums.ToString(); //加载表体 initGrid(); initGrid_Sub(); int i = 0; foreach (Model.ClsSc_StationOutBillSub oSub in BillOld.DetailColl) { if (i >= grdSub.RowCount - 1) { grdSub.Rows.Add(); } //单据固定赋值 grdSub.Rows[i].Cells[HTagCol].Value = "*"; grdSub.Rows[i].Cells[HEntryIDCol].Value = oSub.HEntryID.ToString(); //====================================================================================== // grdSub.Rows[i].Cells[HEmpIDCol].Value = oSub.HEmpID.ToString(); if (oEmp.GetInfoByID(oSub.HEmpID)) { grdSub.Rows[i].Cells[HEmpNumberCol].Value = oEmp.omodel.HNumber; grdSub.Rows[i].Cells[HEmpNameCol].Value = oEmp.omodel.HName; grdSub.Rows[i].Cells[HEmpNoCol].Value = oEmp.omodel.HNumber; grdSub.Rows[i].Cells[HEmpIDCol].Value = oEmp.omodel.HItemID.ToString(); } else { grdSub.Rows[i].Cells[HEmpNumberCol].Value = ""; grdSub.Rows[i].Cells[HEmpNameCol].Value = ""; grdSub.Rows[i].Cells[HEmpNoCol].Value = ""; grdSub.Rows[i].Cells[HEmpIDCol].Value = ""; } i = i + 1; } Sub_OperStatus(); // txtHProcExchBillNo.Enabled = false; txtHProcNo.Enabled = false; Display(); // } //单据完整性判断 未完成 private bool Sub_AllowSave() { //判断该用户名是否有该工站权限 //if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(txtHCenterID.Tag)) == false) //{ // MessageBox.Show("没有该工站权限!", "提示"); // return false; //} //if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew) //{ // //判断是否已经出站 // DataSet Ds; // SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); // Ds = oCn.RunProcReturn("select 1 from Sc_StationOutBillMain where HProcExchInterID=" + lngBillKey + " and HProcExchEntryID=" + lngBillSubKey, "Sc_StationOutBillMain"); // if (Ds == null || Ds.Tables[0].Rows.Count > 0) // { // MessageBox.Show("该工序已出站,请重新扫描!", "提示"); // return false; // } //} ////判断开料是否 上料,如果没有上料 不能出站 //if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew) //{ // //是否是开料工序或者工作中心 // if (DBUtility.ClsPub.isLong(txtHProcID.Tag) == 83556 ) // { // //判断是否已经上料 // DataSet Ds; // SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); // Ds = oCn.RunProcReturn("select 1 from Sc_MaterToSourceBillMain Where HProcExchInterID=" + lngBillKey + " ", "Sc_StationOutBillMain"); // if (Ds == null || Ds.Tables[0].Rows.Count == 0) // { // MessageBox.Show("开料工序没有制作上料单,不能进行出站操作!", "提示"); // return false; // } // } //} ////判断参数内容是否存在空的数据 //foreach (Model.ClsSc_StationOutBillSub_Item oSub in BillOld.DetailColl1) //{ // if (oSub.HValue == "") // { // MessageBox.Show("实际参数值不允许存在空行,如实际情况为空,请输入 '/ ' ", "提示"); // return false; // } // if (oSub.HStd == "" && oSub.HType=="首件") // { // MessageBox.Show("首件标准参数值不允许存在空行,如实际情况为空,请输入 '/ ' ", "提示"); // return false; // } //} //模穴号控制 //if (DBUtility.ClsPub.isStrNull(txtHMaterID.Text) == "13000001197") //{ // string HMXH = ""; // string HZM = ""; // HMXH = DBUtility.ClsPub.isStrNull(txtHMouldNum.Text); // HZM = HMXH.Substring(0, 1); // if (HZM != "G") // { // MessageBox.Show("模穴号错误第一位请重新输入G"); // return false; // } //} if (DBUtility.ClsPub.isStrNull(txtHMaterID.Text) == "3.01.0207" && DBUtility.ClsPub.isStrNull(txtHProcID.Text) == "成品检验") { string HMXH = ""; string HZM = ""; HMXH = DBUtility.ClsPub.isStrNull(txtHMouldNum.Text); HZM = HMXH.Substring(0, 1); if (HZM != "G") { MessageBox.Show("模穴号错误第一位请重新输入G"); return false; } } if (DBUtility.ClsPub.isStrNull(txtHMaterID.Text) == "3.01.0268" && DBUtility.ClsPub.isStrNull(txtHProcID.Text) == "成品检验") { string HMXH = ""; string HZM = ""; HMXH = DBUtility.ClsPub.isStrNull(txtHMouldNum.Text); HZM = HMXH.Substring(0, 1); if (HZM != "X") { MessageBox.Show("模穴号错误第一位请重新输入X"); return false; } } if (DBUtility.ClsPub.isStrNull(txtHMaterID.Text) == "3.01.0211" && DBUtility.ClsPub.isStrNull(txtHProcID.Text) == "成品检验") { string HMXH = ""; string HZM = ""; string HZM2 = ""; string HZM3 = ""; HMXH = DBUtility.ClsPub.isStrNull(txtHMouldNum.Text); HZM = HMXH.Substring(0, 1); HZM2 = HMXH.Substring(2, 1); HZM3 = HMXH.Substring(3, 1); if (HZM != "0") { MessageBox.Show("模穴号错误第一位请重新输入0"); return false; } if (HZM2 != "0") { MessageBox.Show("模穴号错误第三位请重新输入0"); return false; } if (HZM3 != "0") { MessageBox.Show("模穴号错误第四位请重新输入0"); return false; } } if (DBUtility.ClsPub.isStrNull(txtHMaterID.Text) == "3.01.0266" && DBUtility.ClsPub.isStrNull(txtHProcID.Text) == "成品检验") { string HMXH = ""; string HZM = ""; string HZM2 = ""; string HZM3 = ""; HMXH = DBUtility.ClsPub.isStrNull(txtHMouldNum.Text); HZM = HMXH.Substring(0, 1); HZM2 = HMXH.Substring(2, 1); HZM3 = HMXH.Substring(3, 1); if (HZM != "0") { MessageBox.Show("模穴号错误第一位请重新输入0"); return false; } if (HZM2 != "0") { MessageBox.Show("模穴号错误第三位请重新输入0"); return false; } if (HZM3 != "0") { MessageBox.Show("模穴号错误第四位请重新输入0"); return false; } } if (DBUtility.ClsPub.isStrNull(txtHMaterID.Text) == "3.01.0267" && DBUtility.ClsPub.isStrNull(txtHProcID.Text) == "成品检验") { string HMXH = ""; string HZM = ""; string HZM2 = ""; string HZM3 = ""; HMXH = DBUtility.ClsPub.isStrNull(txtHMouldNum.Text); HZM = HMXH.Substring(0, 1); HZM2 = HMXH.Substring(2, 1); HZM3 = HMXH.Substring(3, 1); if (HZM != "0") { MessageBox.Show("模穴号错误第一位请重新输入0"); return false; } if (HZM2 != "0") { MessageBox.Show("模穴号错误第三位请重新输入0"); return false; } if (HZM3 != "0") { MessageBox.Show("模穴号错误第四位请重新输入0"); return false; } } //必输项目是否为空 if (DBUtility.ClsPub.isLong(lngBillKey) <= 0) { MessageBox.Show("流转卡没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(lngBillSubKey) <= 0) { MessageBox.Show("流水号2没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHProcNo.Text) <= 0) { MessageBox.Show("流水号没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isStrNull(txtHProcExchBillNo.Text) == "") { MessageBox.Show("流转卡号没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHMaterID.Tag) == 0) { MessageBox.Show("产品没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHGroupID.Tag) == 0) { MessageBox.Show("生产班组没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHProcID.Tag) == 0) { MessageBox.Show("当前工序没有选择!", "提示"); return false; } //if (DBUtility.ClsPub.isLong(txtHPayProcID.Tag) == 0) //{ // MessageBox.Show("当前核算工序没有选择!", "提示"); // return false; //} if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0) { MessageBox.Show("操作员没有选择!", "提示"); return false; } //if (DBUtility.ClsPub.isLong(txtHQCCheckID.Tag) == 0) //{ // MessageBox.Show("检验员没有选择!", "提示"); // return false; //} if (DBUtility.ClsPub.isLong(txtHSourceID.Tag) == 0) { MessageBox.Show("生产资源没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHCenterID.Tag) == 0) { MessageBox.Show("工作中心没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isDoule(txtHQty.Text) + DBUtility.ClsPub.isDoule(txtHWasterQty.Text) + DBUtility.ClsPub.isDoule(txtHBadCount.Text) <= 0) { MessageBox.Show("数量不能为0!", "提示"); return false; } if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) < 0) { MessageBox.Show("合格个数不能小于0!", "提示"); return false; } if (DBUtility.ClsPub.isDoule(txtHWasterQty.Text.Trim()) < 0) { MessageBox.Show("不合格数不能小于0!", "提示"); return false; } if (DBUtility.ClsPub.isDoule(txtHBadCount.Text.Trim()) < 0) { MessageBox.Show("不良品数不能小于0!", "提示"); return false; } if (DBUtility.ClsPub.isDoule(txtHWorkTimes.Text) <= 0) { MessageBox.Show("工时必须大于0!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHEmpID2.Tag) == 0 && DBUtility.ClsPub.isStrNull(txtHEmpID2.Text.Trim()) != "") { MessageBox.Show("操作员2没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHEmpID3.Tag) == 0 && DBUtility.ClsPub.isStrNull(txtHEmpID3.Text.Trim()) != "") { MessageBox.Show("操作员3没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHEmpID4.Tag) == 0 && DBUtility.ClsPub.isStrNull(txtHEmpID4.Text.Trim()) != "") { MessageBox.Show("操作员4没有选择!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHEmpID5.Tag) == 0 && DBUtility.ClsPub.isStrNull(txtHEmpID5.Text.Trim()) != "") { MessageBox.Show("操作员5没有选择!", "提示"); return false; } //if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) == 0.0) //{ // MessageBox.Show("移交PCS数不能为0!", "提示"); // return false; //} //if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanQty.Text.Trim())) //{ // MessageBox.Show("移交PCS数不能大于进站 PCS数!", "提示"); // return false; //} //if (DBUtility.ClsPub.isDoule(txtHPieceQty.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanPieceQty.Text.Trim())) //{ // MessageBox.Show("移交PNL数不能大于进站 PNL数!", "提示"); // return false; //} //if (DBUtility.ClsPub.isDoule(txtHWasterQty.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanQty.Text.Trim())) //{ // MessageBox.Show("报废PCS数不能大于进站 PCS数!", "提示"); // return false; //} //if (DBUtility.ClsPub.isDoule(txtHBadPNL.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanPieceQty.Text.Trim())) //{ // MessageBox.Show("报废PNL数不能大于进站 PNL数!", "提示"); // return false; //} //单据号是否重复 if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, txtHBillNo.Text.Trim(), BillStatus, BillOld.omodel.HInterID)) { MessageBox.Show("单据号重复!", "提示"); return false; } //根据不同客户,对录入总工时与标准总工时进行对比判断 SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); long sMaterID = DBUtility.ClsPub.isLong(this.txtHMaterID.Tag); long sProcID = DBUtility.ClsPub.isLong(this.txtHProcID.Tag); double sQty = DBUtility.ClsPub.isDoule(this.txtHQty.Text); double sBadCount = DBUtility.ClsPub.isDoule(this.txtHBadCount.Text); double sWasterQty = DBUtility.ClsPub.isDoule(this.txtHWasterQty.Text); double sWorkTimes = DBUtility.ClsPub.isSingle(this.txtHWorkTimes.Text); DataSet Ds; Ds = oCn.RunProcReturn("exec h_p_MES_StationOutBill_WorkTimesCtrl " + sMaterID.ToString() + "," + sProcID.ToString() + "," + sQty.ToString() + "," + sBadCount.ToString() + "," + sWasterQty.ToString() + "," + sWorkTimes.ToString(), "h_p_MES_StationOutBill_WorkTimesCtrl"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { MessageBox.Show("录入总工时与标准总工时对比判断失败!", "提示"); return false; } else { if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) == 1) { MessageBox.Show(DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"])); return false; } else if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) == 2) { MessageBox.Show(DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"])); } } return true; } //保存单据 private bool Sub_SaveBill() { Model.ClsSc_StationOutBillSub oBillSub = new Model.ClsSc_StationOutBillSub(); //判断权限 if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName)) { return false; } // bool bResult; BillNew = new DAL.ClsSc_StationOutBill(); //失去焦点 lblCaption.Focus(); if (!Sub_AllowSave())//单据完整性判断 return false; //赋值ID if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify) BillNew.omodel.HInterID = BillOld.omodel.HInterID; //主类赋值 //判断会计期是否合理 string s = ""; int sYear = 0; int sPeriod = 0; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DBUtility.ClsPub.isDate(this.txtHStationOutTime.Text), ref sYear, ref sPeriod, ref s) == false) { MessageBox.Show(s, "提示"); return false; } // BillNew.omodel.HYear = sYear; BillNew.omodel.HPeriod = sPeriod; BillNew.omodel.HBillNo = this.txtHBillNo.Text.Trim(); BillNew.omodel.HICMOBillNo = this.txtHICMOBillNo.Text.Trim(); BillNew.omodel.HICMOInterID = DBUtility.ClsPub.isLong(this.txtHICMOBillNo.Tag); BillNew.omodel.HProcExchInterID = lngBillKey; BillNew.omodel.HProcExchEntryID = lngBillSubKey; BillNew.omodel.HProcExchBillNo = this.txtHProcExchBillNo.Text.Trim(); BillNew.omodel.HProcID = DBUtility.ClsPub.isLong(this.txtHProcID.Tag); BillNew.omodel.HPayProcID = DBUtility.ClsPub.isLong(this.txtHPayProcID.Tag); BillNew.omodel.HMaterID = DBUtility.ClsPub.isLong(this.txtHMaterID.Tag); BillNew.omodel.HStationOutTime = DBUtility.ClsPub.isDate(this.txtHStationOutTime.Text); BillNew.omodel.HEmpID = DBUtility.ClsPub.isLong(this.txtHEmpID.Tag); BillNew.omodel.HEmpID2 = DBUtility.ClsPub.isLong(this.txtHEmpID2.Tag); BillNew.omodel.HEmpID3 = DBUtility.ClsPub.isLong(this.txtHEmpID3.Tag); BillNew.omodel.HEmpID4 = DBUtility.ClsPub.isLong(this.txtHEmpID4.Tag); BillNew.omodel.HEmpID5 = DBUtility.ClsPub.isLong(this.txtHEmpID5.Tag); BillNew.omodel.HSourceID = DBUtility.ClsPub.isLong(this.txtHSourceID.Tag); BillNew.omodel.HSourceID2 = DBUtility.ClsPub.isLong(this.txtHSourceID2.Tag); BillNew.omodel.HSourceID3 = DBUtility.ClsPub.isLong(this.txtHSourceID3.Tag); BillNew.omodel.HSourceID4 = DBUtility.ClsPub.isLong(this.txtHSourceID4.Tag); BillNew.omodel.HSourceID5 = DBUtility.ClsPub.isLong(this.txtHSourceID5.Tag); BillNew.omodel.HGroupID = DBUtility.ClsPub.isLong(this.txtHGroupID.Tag); BillNew.omodel.HICMOQty = DBUtility.ClsPub.isDoule(this.txtHICMOQty.Text); BillNew.omodel.HPlanQty = DBUtility.ClsPub.isDoule(this.txtHPlanQty.Text); BillNew.omodel.HDSQty = DBUtility.ClsPub.isDoule(this.txtHDSQty.Text); BillNew.omodel.HQty = DBUtility.ClsPub.isDoule(this.txtHQty.Text); BillNew.omodel.HPieceQty = DBUtility.ClsPub.isDoule(this.txtHPieceQty.Text); BillNew.omodel.HPlanPieceQty = DBUtility.ClsPub.isDoule(this.txtHPlanPieceQty.Text); BillNew.omodel.HSourceName = DBUtility.ClsPub.isStrNull(this.txtHSourceName.Text); BillNew.omodel.HBadPNL = DBUtility.ClsPub.isDoule(this.txtHBadPNL.Text); BillNew.omodel.HWasterQty = DBUtility.ClsPub.isDoule(this.txtHWasterQty.Text); BillNew.omodel.HBadCount = DBUtility.ClsPub.isDoule(this.txtHBadCount.Text); BillNew.omodel.HChongQty = DBUtility.ClsPub.isDoule(this.txtHChongQty.Text); BillNew.omodel.HCenterID = DBUtility.ClsPub.isLong(this.txtHCenterID.Tag); BillNew.omodel.HProcNo = DBUtility.ClsPub.isInt(this.txtHProcNo.Text); BillNew.omodel.HOrderProcNO = DBUtility.ClsPub.isStrNull(this.txtHOrderProcNO.Text); BillNew.omodel.HLastSubProc = chkHLastSubProc.Checked; BillNew.omodel.HRemark = txtHRemark.Text; BillNew.omodel.HMainSourceInterID = sHMainSourceInterID; BillNew.omodel.HMainSourceBillNo = sHMainSourceBillNo; BillNew.omodel.HMainSourceBillType = "3790"; BillNew.omodel.HPriceRate = DBUtility.ClsPub.isDoule(this.txtHPriceRate.Text); BillNew.omodel.HMouldNum = txtHMouldNum.Text; BillNew.omodel.HWorkTimes = DBUtility.ClsPub.isSingle(this.txtHWorkTimes.Text); BillNew.omodel.HQCCheckID = DBUtility.ClsPub.isLong(this.txtHQCCheckID.Tag); BillNew.omodel.HSourceNameList = DBUtility.ClsPub.isStrNull(this.txtHSourceNameList.Text); BillNew.omodel.HPersonNums = DBUtility.ClsPub.isLong(this.txtHPersonNums.Text); BillNew.omodel.HMachineNums = DBUtility.ClsPub.isLong(this.txtHMachineNums.Text); //明细类赋值 BillNew.DetailColl = new List(); for (int i = 0; i <= grdSub.RowCount - 1; i++) { if (ClsPub.isLong(grdSub.Rows[i].Cells[HEmpIDCol].Value) != 0) { Model.ClsSc_StationOutBillSub oSub = new Model.ClsSc_StationOutBillSub(); //固定赋值======================================== oSub.HEntryID = DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[HEntryIDCol].Value); oSub.HRemark = ""; oSub.HSourceInterID = lngBillKey; oSub.HSourceEntryID = lngBillSubKey; oSub.HSourceBillType = "3772"; oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(this.txtHProcExchBillNo.Text); oSub.HRelationQty = 0; oSub.HRelationMoney = 0; oSub.HCloseMan = ""; oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(null); oSub.HCloseType = false; //============================= oSub.HProcID = 0; oSub.HProcNo = DBUtility.ClsPub.isLong(txtHProcNo.Text); oSub.HMaterID = DBUtility.ClsPub.isLong(this.txtHMaterID.Tag); oSub.HEmpID = DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[HEmpIDCol].Value); oSub.HSourceID = DBUtility.ClsPub.isLong(this.txtHSourceID.Tag); oSub.HQty = 0; oSub.HPieceQty = 0; oSub.HSourceName =""; oSub.HBillNo_bak = BillNew.omodel.HBillNo; oSub.HProcExchInterID = lngBillKey; oSub.HProcExchEntryID = lngBillSubKey; oSub.HProcExchBillNo = DBUtility.ClsPub.isStrNull(this.txtHProcExchBillNo.Text); BillNew.DetailColl.Add(oSub); } } //明细类赋值2 BillNew.DetailColl1 = BillOld.DetailColl1; //保存完毕后处理 if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew) { bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo); } else { bResult = BillNew.ModifyBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo); } //提示 if (bResult == true) { BillChange = true; MessageBox.Show("单据存盘完毕!单据号:" + this.txtHBillNo.Text.Trim() + ClsPub.sExeReturnInfo , "提示"); if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; BillOld.omodel.HInterID = BillNew.omodel.HInterID; this.Sub_ShowBill(); } else if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; } this.Sub_OperStatus(); return true; } else { MessageBox.Show("保存失败!原因:" + ClsPub.sExeReturnInfo, "提示"); return false; } } #endregion #region 窗体处理方法 //初始化GRID private void initGrid() { DBUtility.Xt_BaseBillFun.initGridMESList(grdCardList, this.Name + "grdCardList"); grdCardList.DataSource = null; } private void Display() { ClsCN SubCn = new ClsCN(); DataSet DSet; string sSql = ""; string sWhere = ""; sWhere = sWhere + "" + DBUtility.ClsPub.isStrNull(txtHProcID.Tag); sWhere = sWhere + "," + DBUtility.ClsPub.isStrNull(txtHSourceID.Tag); sWhere = sWhere + "," + DBUtility.ClsPub.isStrNull(DBUtility.ClsPub.CurUserName); sSql = " exec h_p_MES_NowStationOutBillList " + sWhere; // DSet = SubCn.RunProcReturn(sSql, "h_p_MES_NowStationOutBillList", ref DBUtility.ClsPub.sExeReturnInfo); //生成首行标题 if (DSet == null) { //MessageBox.Show("没有返回任何结果,请在过滤框中点击【恢复】按钮,尝试再次查询!" + DBUtility.ClsPub.sExeReturnInfo); return; } //释放冻结 // grdCardList.DataSource = DSet.Tables[0].DefaultView; //设置合计列 //string sTotalCol = ""; //sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet); //string[] sT; //sT = sTotalCol.Split(Convert.ToChar(",")); //oSumGrid.BuildTotalCols(sT); // //冻结 int FrCol = 0; string s = "是"; DBUtility.Xt_BaseBillFun.DisplayGrid(grdCardList, this.Name + "grdCardList", s, FrCol); //画线 //GraphLine(); //Total(); //判断金额权限 // } //初始化GRID Sub private void initGrid_Sub() { grdSub.RowCount = 0; grdSub.ColumnCount = 7; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name + "1"); //= grdSub.Columns[HTagCol].HeaderText = "序号"; grdSub.Columns[HEmpNoCol].HeaderText = "工号"; grdSub.Columns[HEmpNumberCol].HeaderText = "职员代码"; grdSub.Columns[HEmpNameCol].HeaderText = "职员"; ////固定赋值===================================================== //============================================================================= //下拉框 //格式化 ////隐藏列 grdSub.Columns[HEmpIDCol].Visible = false; grdSub.Columns[HEntryIDCol].Visible = false; grdSub.Columns[HSnoCol].Visible = false; //设置可编辑列 string sAllowCol = HEmpNoCol.ToString() ; //设置合计列 string sTotalCol = ""; //格式化网格 DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid_Sub); } //网格下拉框 private void cmb_TextChange(object sender, EventArgs e) { grdSub.CurrentCell.Value = cmb.Text.ToString();  //下拉框选择时,就把值赋给所在的单元格   } //帮助函数 private void Sub_GridKey(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit) { if (!grdStatus) { return; } } //帮助函数 private void Sub_GridKey_Sub(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (!grdStatus) { return; } oSumGrid.EditStatus = true; switch (sKeyCode) { case 118: //F7 { switch (sCol) { case HEmpNoCol: if (oEmp.RefreshView()) { if (oEmp.GetInfoByID(oEmp.oModel.HItemID)) { oEdit.Text = oEmp.omodel.HNumber; grdSub.Rows[sRow].Cells[HEmpNoCol].Value = oEmp.oModel.HNumber; grdSub.Rows[sRow].Cells[HEmpIDCol].Value = oEmp.oModel.HItemID; grdSub.Rows[sRow].Cells[HEmpNumberCol].Value = oEmp.oModel.HNumber; grdSub.Rows[sRow].Cells[HEmpNameCol].Value = oEmp.oModel.HName; } else { grdSub.Rows[sRow].Cells[HEmpNoCol].Value = ""; grdSub.Rows[sRow].Cells[HEmpIDCol].Value = ""; grdSub.Rows[sRow].Cells[HEmpNumberCol].Value = ""; grdSub.Rows[sRow].Cells[HEmpNameCol].Value = ""; } } else { grdSub.Rows[sRow].Cells[HEmpNoCol].Value =""; grdSub.Rows[sRow].Cells[HEmpIDCol].Value = ""; grdSub.Rows[sRow].Cells[HEmpNumberCol].Value = ""; grdSub.Rows[sRow].Cells[HEmpNameCol].Value = ""; } break; default: break; } break; } case 117: //F6 { switch (sCol) { default: break; } break; } default: break; } } #endregion private void cmdHMaterID_Click(object sender, EventArgs e) { DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View(); if (oMater.RefreshView()) { txtHMaterID.Tag = oMater.oModel.HItemID.ToString(); if (oMater.GetInfoByID(oMater.oModel.HItemID)) { txtHMaterID.Text = oMater.omodel.HNumber; txtHMaterName.Text = oMater.omodel.HName; txtHMaterModel.Text = oMater.omodel.HModel; } else { txtHMaterID.Text = ""; txtHMaterName.Text = ""; txtHMaterModel.Text = ""; } } else { txtHMaterID.Text = ""; txtHMaterName.Text = ""; txtHMaterModel.Text = ""; } } private void txtHMaterID_TextChanged(object sender, EventArgs e) { if (txtHMaterID.Text.Trim() == "") { this.txtHMaterID.Tag = "0"; this.txtHMaterName.Text = ""; this.txtHMaterModel.Text = ""; } } private void cmdHEmpID_Click(object sender, EventArgs e) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.RefreshView()) { txtHEmpID.Text = oEmp.oModel.HNumber; txtHEmpID.Tag = oEmp.oModel.HItemID.ToString(); txtHEmpName.Text = oEmp.oModel.HName; } else { txtHEmpID.Text = ""; } } private void txtHEmpID_TextChanged(object sender, EventArgs e) { if (txtHEmpID.Text.Trim() == "") { txtHEmpID.Tag = 0; txtHEmpName.Text = ""; } } private void cmdHSourceID_Click(object sender, EventArgs e) { DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); if (oSource.RefreshView()) { txtHSourceID.Text = oSource.oModel.HNumber; txtHSourceID.Tag = oSource.oModel.HItemID.ToString(); txtHSourceName.Text = oSource.oModel.HName; } else { txtHSourceID.Text = ""; txtHSourceName.Text =""; } } private void txtHSourceID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHSourceID); txtHSourceName.Text = ""; } private void cmdHProcID_Click(object sender, EventArgs e) { //BLL.ClsBaseSelect_CLD.SetTextByProc_CLD(txtHProcID); //if (lngBillKey == 0) //{ // MessageBox.Show("请先扫描LOT卡!","提示"); // return; //} //else //{ // DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); // if (oProc.RefreshViewByLot(lngBillKey)) // { // lngBillSubKey = oProc.oModel.HEntryID; // txtHProcID.Text = oProc.oModel.HName; // txtHProcID.Tag = oProc.oModel.HItemID.ToString(); // Sub_AddBill(); // } // else // { // lngBillSubKey = 0; // txtHProcID.Text = ""; // txtHProcID.Tag = 0; // } //} } private void txtHProcID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHProcID); } private void cmdHGroupID_Click(object sender, EventArgs e) { BLL.ClsBaseSelect.SetTextByGroup(txtHGroupID, txtHGroupName); } private void txtHGroupID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHGroupID); txtHGroupName.Text = ""; } private void txtHProcExchBillNo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Return) { if (txtHProcExchBillNo.Text.Trim() == "") { MessageBox.Show("工序流转卡卡号,不能为空!"); return; } DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); string sBillNo = txtHProcExchBillNo.Text.Trim(); //得到信息 Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "'", "h_v_Sc_ProcessExchangeBillList"); //写入信息 if (Ds == null || Ds.Tables[0].Rows.Count == 0) { txtHProcExchBillNo.Text = ""; MessageBox.Show("未查询到流转卡信息!"); return; } for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { Sub_WriteInForm_SM(Ds.Tables[0], i); } //Sub_ShowBill(); txtHProcNo.Focus(); txtHProcExchBillNo.Enabled = false; } } //根据TABLE写入界面 private void Sub_WriteInForm_SM(DataTable oTable, int i) { // this.txtHICMOBillNo.Tag = oTable.Rows[0]["hicmointerid"].ToString(); this.txtHICMOBillNo.Text = oTable.Rows[0]["任务单号"].ToString(); this.txtHMaterID.Tag = oTable.Rows[0]["HMaterID"].ToString(); this.txtHMaterName.Text = oTable.Rows[0]["产品"].ToString(); this.txtHMaterID.Text = oTable.Rows[0]["产品代码"].ToString(); this.txtHMaterModel.Text = oTable.Rows[0]["规格型号"].ToString(); //this.txtHBatchNo.Text = oTable.Rows[0]["批号"].ToString(); //this.txtHUnitID.Tag = oTable.Rows[0]["HUnitID"].ToString(); //this.txtHUnitID.Text = oTable.Rows[0]["单位"].ToString(); //this.txtHQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["生产数量"], 0); this.txtHQty.Text = "0"; this.txtHPieceQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["流转卡数量"], 0); this.txtHPlanQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["流转卡数量"], 0); lngBillKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["hmainid"]); //lngBillSubKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HSubID"]); txtHProcExchBillNo.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["单据号"]); txtHICMOQty.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["任务单数量"]); txtHOrderProcNO.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["订单跟踪号"]); //加载表体 Display(); } private void txtHProcID_KeyDown(object sender, KeyEventArgs e) { //if (e.KeyCode == Keys.Enter) //{ // if (lngBillKey == 0) // { // MessageBox.Show("请先扫描LOT卡!", "提示"); // return; // } // if (DBUtility.ClsPub.isStrNull(txtHProcID.Text) != "") // { // DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); // if (oProc.GetInfoByNumber_Lot(DBUtility.ClsPub.isStrNull(txtHProcID.Text))) // { // lngBillSubKey = oProc.omodel.HEntryID; // txtHProcID.Text = oProc.omodel.HName; // txtHProcID.Tag = oProc.omodel.HItemID; // Show(); // } // else // { // lngBillSubKey = 0; // txtHProcID.Text = ""; // txtHProcID.Tag = 0; // } // } // else // { // lngBillSubKey = 0; // txtHProcID.Text = ""; // txtHProcID.Tag = 0; // } //} } private void txtHEmpID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DBUtility.ClsPub.isStrNull(txtHEmpID.Text) != "") { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHEmpID.Text))) { txtHEmpID.Text = oEmp.omodel.HNumber; txtHEmpID.Tag = oEmp.omodel.HItemID; txtHEmpName.Text = oEmp.omodel.HName; txtHQty.Focus(); } else { txtHEmpID.Text = ""; txtHEmpID.Tag = 0; txtHEmpName.Text = ""; } } else { txtHEmpID.Text = ""; txtHEmpID.Tag = 0; txtHEmpName.Text = ""; } txtHQty.Focus(); } } private void txtHSourceID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DBUtility.ClsPub.isStrNull(txtHSourceID.Text) != "") { DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); if (oSource.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHSourceID.Text))) { txtHSourceID.Text = oSource.omodel.HNumber; txtHSourceID.Tag = oSource.omodel.HItemID; txtHSourceName.Text = oSource.omodel.HName; } else { txtHSourceID.Text = ""; txtHSourceID.Tag = 0; txtHSourceName.Text = ""; } } else { txtHSourceID.Text = ""; txtHSourceID.Tag = 0; txtHSourceName.Text = ""; } txtHMouldNum.Focus(); } } private void txtHGroupID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { // DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); // Int64 HCenterID = Pub_Class.ClsPub.isLong(txtHCenterID.Tag); // //获取控件位置 // int x = 0; int y = 0; // BLL.ClsPub_BLL.SetXY(this, panel4, gbUp, txtHGroupID, ref x, ref y); // //选择基础 // BLL.ClsBaseDownSelect.SetTextByGroup(txtHGroupID, HCenterID, x, y); // Int64 HGroupID = Pub_Class.ClsPub.isLong(txtHGroupID.Tag.ToString()); // BillOld.ShowEmpByGroup(HGroupID, ref DBUtility.ClsPub.sExeReturnInfo, false); // int i = 0; // foreach (Model.ClsSc_StationOutBillSub oSub in BillOld.DetailColl) // { // if (i >= grdSub.RowCount - 1) // grdSub.Rows.Add(); // grdSub.Rows[i].Cells[HEmpIDCol].Value = oSub.HEmpID.ToString(); // if (oEmp.GetInfoByID(oSub.HEmpID)) // { // grdSub.Rows[i].Cells[HEmpNoCol].Value = oEmp.omodel.HNumber; // // grdSub.Rows[i].Cells[HEmpIDCol].Value = oEmp.oModel.HItemID; // grdSub.Rows[i].Cells[HEmpNumberCol].Value = oEmp.omodel.HNumber; // grdSub.Rows[i].Cells[HEmpNameCol].Value = oEmp.omodel.HName; // } // else // { // grdSub.Rows[i].Cells[HEmpNoCol].Value = ""; // // grdSub.Rows[i].Cells[HEmpIDCol].Value = oEmp.oModel.HItemID; // grdSub.Rows[i].Cells[HEmpNumberCol].Value = ""; // grdSub.Rows[i].Cells[HEmpNameCol].Value = ""; // } // i = i + 1; // } // //GRID允许刷新 //// DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // // // //Sub_OperStatus(); if (DBUtility.ClsPub.isStrNull(txtHGroupID.Text) != "") { DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); if (oGroup.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHGroupID.Text))) { txtHGroupID.Text = oGroup.omodel.HNumber; txtHGroupID.Tag = oGroup.omodel.HItemID; txtHGroupName.Text = oGroup.omodel.HName; } else { txtHGroupID.Text = ""; txtHGroupID.Tag = 0; txtHGroupName.Text = ""; } } else { txtHGroupID.Text = ""; txtHGroupID.Tag = 0; txtHGroupName.Text = ""; } txtHEmpID.Focus(); } } private void cmdAddNew_Click(object sender, EventArgs e) { lngBillKey = 0; lngBillSubKey = 0; Sub_AddBill(); } private void grdSub_KeyDown(object sender, KeyEventArgs e) { } #region 基本不变 //网格编辑前判断 private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { } private void grdMain_Scroll(object sender, ScrollEventArgs e) { } //网格编辑后处理 private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e) { } DataGridViewTextBoxEditingControl EditingControl; private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { } private void EditingControl_KeyDown(object sender, KeyEventArgs e) { } private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e) { } private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { } //网格编辑前判断 private void grdSub_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { int i = grdSub.CurrentCell.ColumnIndex; if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid_Sub, i)) { e.Cancel = true; } } //滚动条滚动时,单元格位置发生变化,也得隐藏下拉框控件,不然下拉框控件位置不动就乱了 private void grdSub_Scroll(object sender, ScrollEventArgs e) { cmb.Visible = false; //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid_Sub); oSumGrid_Sub.DisplayCurRow(); } //网格编辑后处理 private void grdSub_CellEndEdit(object sender, DataGridViewCellEventArgs e) { //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid_Sub); // if (this.EditingControl_Sub != null) //释放事件 { EditingControl_Sub.KeyDown -= new KeyEventHandler(this.EditingControl_Sub_KeyDown); this.EditingControl = null; } } DataGridViewTextBoxEditingControl EditingControl_Sub; private void grdSub_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (grdSub.CurrentCell != null) { if (e.Control is DataGridViewTextBoxEditingControl) { this.EditingControl_Sub = (DataGridViewTextBoxEditingControl)e.Control; //增加委托处理 this.EditingControl_Sub.KeyDown += new KeyEventHandler(this.EditingControl_Sub_KeyDown); } } } private void EditingControl_Sub_KeyDown(object sender, KeyEventArgs e) { //业务处理 Sub_GridKey_Sub(e.KeyValue, grdSub.CurrentRow.Index, grdSub.CurrentCell.ColumnIndex, EditingControl_Sub); } private void grdSub_RowHeadersWidthChanged(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid_Sub); } //当列的宽度变化时,下拉框控件先隐藏起来,不然单元格变大下拉框控件无法跟着变大哦 private void grdSub_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { cmb.Visible = false; DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid_Sub); } #endregion //单元格被单击,判断是否是放下拉框控件的那一列 private void grdSub_CellClick(object sender, DataGridViewCellEventArgs e) { //if (e.ColumnIndex == SecHTypeCol) //{ // _Rectangle = grdSub.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); //得到所在单元格位置和大小   // cmb.Size = new Size(_Rectangle.Width, _Rectangle.Height); //把单元格大小赋给时间控件   // cmb.Location = new Point(_Rectangle.X, _Rectangle.Y); //把单元格位置赋给时间控件   // cmb.Visible = true;  //可以显示控件了   //} //else // cmb.Visible = false; } private void bclk_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "1"); } private void cmdBF_Click(object sender, EventArgs e) { } private void txtHSourceName_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHEmpID.Select(); } } private void txtHQty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //txtHWasterQty.Select(); //cmdOK.Focus(); txtHQCCheckID.Focus(); } } private void txtHPieceQty_KeyDown(object sender, KeyEventArgs e) { } private void txtHWasterQty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { cmdOK.Focus(); } } private void txtHBadPNL_KeyDown(object sender, KeyEventArgs e) { } private void txtHPieceQty_Leave(object sender, EventArgs e) { //txtHBadPNL.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanPieceQty.Text) - ClsPub.isDoule(txtHPieceQty.Text)); } private void txtHQty_Leave(object sender, EventArgs e) { //txtHWasterQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanQty.Text) - ClsPub.isDoule(txtHQty.Text)); } private void txtHWasterQty_Leave(object sender, EventArgs e) { //txtHQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanQty.Text) - ClsPub.isDoule(txtHWasterQty.Text)); } private void txtHBadPNL_Leave(object sender, EventArgs e) { //txtHPieceQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanPieceQty.Text) - ClsPub.isDoule(txtHBadPNL.Text)); } //编辑单据 private void Sub_EditBill() { //判断权限 if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName)) { return ; } ////判断该用户名是否有该工站权限 //if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(txtHCenterID.Tag)) == false) //{ // MessageBox.Show("没有该工站权限!", "提示"); // return; //} string s = ""; if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false) { MessageBox.Show("此单据有错误!", "提示"); return; } //判断是否可编辑 // this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; this.Sub_OperStatus();//刷新TOOLBAR // txtHBillNo.Enabled = false; //单据号不允许修改 } private void cmdXG_Click(object sender, EventArgs e) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; //判断生产订单是否已结案,要求计划手工反结案 判断是否存在 相同单据号 的入库单 ds = oCn.RunProcReturn("exec h_p_MES_StationOutBill_DelCtrl '" + BillOld.omodel.HBillNo + "'", "h_p_MES_StationOutBill_DelCtrl"); if (ds == null) { MessageBox.Show("判断关联失败!"); return; } if (ds.Tables[0].Rows.Count > 0 && Pub_Class.ClsPub.isInt(ds.Tables[0].Rows[0][0]) == 2) { MessageBox.Show(Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1])); return; } Sub_EditBill(); } private void cmdChecker_Click(object sender, EventArgs e) { QC_NoPassProdCheckBill oBF = new QC_NoPassProdCheckBill(); oBF.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oBF.HMainSourceInterID = BillOld.omodel.HInterID; oBF.HProcExchInterID = lngBillKey; oBF.HProcExchEntryID = lngBillSubKey; oBF.HBillSubType = "不良评审"; oBF.txtHLotNo.Text = txtHProcExchBillNo.Text; oBF.txtHOrderProcNo.Text = txtHOrderProcNO.Text; oBF.txtHMaterID.Text = txtHMaterName.Text; oBF.txtHMaterNumber.Text = txtHMaterID.Text; oBF.txtHModel.Text = txtHMaterModel.Text; oBF.txtHMaterID.Tag = txtHMaterID.Tag; oBF.txtHProcID.Tag = txtHProcID.Tag; oBF.txtHProcID.Text = txtHProcID.Text; oBF.txtHWorkCenterID.Text = txtHCenterID.Text; oBF.txtHWorkCenterID.Tag = txtHCenterID.Tag; oBF.txtHICMOInterID.Text = Pub_Class.ClsPub.isStrNull(txtHICMOBillNo.Tag); oBF.txtHICMOBillNo.Text = txtHICMOBillNo.Text; oBF.txtHProcExchQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanQty.Text)); oBF.txtHPlanQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadCount.Text)); oBF.txtHPlanPNL.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadPNL.Text)); oBF.txtHBadPNL.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadPNL.Text)); oBF.txtHBadQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadCount.Text)); oBF.ShowDialog(); if (oBF.BillChange) { this.Sub_ShowBill(); } } //报废品质确认按钮 private void cmdBFChecker_Click(object sender, EventArgs e) { QC_NoPassProdCheckBill oBF = new QC_NoPassProdCheckBill(); oBF.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; oBF.HMainSourceInterID = BillOld.omodel.HInterID; oBF.HProcExchInterID = lngBillKey; oBF.HProcExchEntryID = lngBillSubKey; oBF.HBillSubType = "报废评审"; oBF.txtHLotNo.Text = txtHProcExchBillNo.Text; oBF.txtHOrderProcNo.Text = txtHOrderProcNO.Text; oBF.txtHMaterID.Text = txtHMaterName.Text; oBF.txtHMaterNumber.Text = txtHMaterID.Text; oBF.txtHModel.Text = txtHMaterModel.Text; oBF.txtHMaterID.Tag = txtHMaterID.Tag; oBF.txtHProcID.Tag = txtHProcID.Tag; oBF.txtHProcID.Text = txtHProcID.Text; oBF.txtHWorkCenterID.Text = txtHCenterID.Text; oBF.txtHWorkCenterID.Tag = txtHCenterID.Tag; oBF.txtHICMOInterID.Text = Pub_Class.ClsPub.isStrNull(txtHICMOBillNo.Tag); oBF.txtHICMOBillNo.Text = txtHICMOBillNo.Text; oBF.txtHProcExchQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanQty.Text)); oBF.txtHPlanQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHWasterQty.Text)); oBF.txtHPlanPNL.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadPNL.Text)); oBF.txtHBadPNL.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadPNL.Text)); oBF.txtHBadQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHWasterQty.Text)); oBF.ShowDialog(); if (oBF.BillChange) { this.Sub_ShowBill(); } } private void label20_Click(object sender, EventArgs e) { } private void txtHProcNo_KeyDown(object sender, KeyEventArgs e) { DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); string sProcNo = txtHProcNo.Text.Trim(); string sBillNo = txtHProcExchBillNo.Text.Trim(); if (e.KeyCode == Keys.Return) { if (txtHProcExchBillNo.Enabled == true) { MessageBox.Show("流转卡没有扫描,或者没有按回车键,请扫描流转卡或者在流转卡文本框中按回车键!"); return; } //得到信息(委外标记为0时) //Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 工序号='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList"); Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 下道流转工序<>'转' and 委外标记=0 and 流转标记=1 and 工序号='" + sProcNo + "' ", "h_v_Sc_ProcessExchangeBillList"); //写入信息 if (Ds == null || Ds.Tables[0].Rows.Count == 0) { txtHProcNo.Text = ""; MessageBox.Show("流水号错误,请重新输入!"); return; } for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { Sub_WriteInForm_SM2(Ds.Tables[0], i); } txtHSourceID.Focus(); //如果是唯一 核算工序则 默认带出 并跳至 职员 //if (oProc.GetSubProcInfoByID(DBUtility.ClsPub.isLong(txtHProcID.Tag))) //{ // txtHPayProcID.Tag = oProc.omodel.HItemID.ToString(); // txtHPayProcID.Text = oProc.omodel.HName; // txtHEmpID.Focus(); //} // } } //根据TABLE写入界面 private void Sub_WriteInForm_SM2(DataTable oTable, int i) { DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); // lngBillKey =DBUtility.ClsPub.isLong(oTable.Rows[0]["hmainid"]); lngBillSubKey =DBUtility.ClsPub.isLong(oTable.Rows[0]["hsubid"]); // this.txtHProcID.Tag = oTable.Rows[0]["HProcID"].ToString(); this.txtHProcID.Text = oTable.Rows[0]["工序"].ToString(); this.txtHCenterID.Tag = oTable.Rows[0]["HCenterID"].ToString(); this.txtHCenterID.Text = oTable.Rows[0]["工作中心"].ToString(); //根据工作中心 带出TOP 1班组 //if (oGroup.GetInfoByCenterID(DBUtility.ClsPub.isLong(this.txtHCenterID.Tag))) //{ // this.txtHGroupID.Text = oGroup.omodel.HName; // this.txtHGroupID.Tag = oGroup.omodel.HItemID.ToString(); //} txtHProcNo.Enabled = false; //根据订单跟踪号 获取 工价系数 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; ds = oCN.RunProcReturn("exec h_p_Sc_GetRateByOrderProcNo_New " + lngBillKey + "," + lngBillSubKey + "", "h_p_Sc_GetRateByOrderProcNo_New", ref DBUtility.ClsPub.sExeReturnInfo); if (ds == null || ds.Tables[0].Rows.Count == 0) { txtHPriceRate.Text = "1"; } else { txtHPriceRate.Text = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[0][0], 4); } // } bool enterkey; protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); //DAL.ClsGy_WorkType_View oWorkType = new DAL.ClsGy_WorkType_View(); DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); enterkey = false; if (keyData == Keys.Enter) //监听回车事件 { if (this.grdSub.IsCurrentCellInEditMode) //如果当前单元格处于编辑模式 { enterkey = true; //把是否点击按钮设置为真 if (grdSub.CurrentCell.RowIndex == grdSub.Rows.Count - 1) { } else { } if (grdSub.CurrentCell.ColumnIndex != HEmpNoCol) { return true; } grdSub.Rows[grdSub.CurrentRow.Index].Cells[grdSub.CurrentCell.ColumnIndex].Value = EditingControl_Sub.Text; string sWhere = Pub_Class.ClsPub.isStrNull(grdSub.Rows[grdSub.CurrentRow.Index].Cells[grdSub.CurrentCell.ColumnIndex].Value); if (grdSub.CurrentCell.ColumnIndex == HEmpNoCol) { string sEmpNo = sWhere; if (oEmp.GetInfoByNumber(sEmpNo)) { grdSub.Rows[grdSub.CurrentRow.Index].Cells[HEmpIDCol].Value = oEmp.omodel.HItemID; grdSub.Rows[grdSub.CurrentRow.Index].Cells[HEmpNameCol].Value = oEmp.omodel.HName; grdSub.Rows[grdSub.CurrentRow.Index].Cells[HEmpNumberCol].Value = oEmp.omodel.HNumber; grdSub.Rows[grdSub.CurrentRow.Index].Cells[HEmpNoCol].Value = oEmp.omodel.HNumber; EditingControl_Sub.Text = oEmp.omodel.HNumber; SendKeys.Send("{Tab}"); SendKeys.Send("{Tab}"); return true; } else { EditingControl_Sub.Text = ""; grdSub.Rows[grdSub.CurrentRow.Index].Cells[HEmpNumberCol].Value = ""; MessageBox.Show("员工工号错误,请重新输入!"); } } return true; } } //继续原来base.ProcessCmdKey中的处理 return base.ProcessCmdKey(ref msg, keyData); int wm_keydown = 256; int wm_syskeydown = 260; bool _disable = false; if (msg.Msg == wm_keydown || msg.Msg == wm_syskeydown) { switch (keyData) { case Keys.Enter: SendKeys.Send("{Tab}"); _disable = true; break; } } } private void txtHPayProcID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); Int64 HMainProcID = Pub_Class.ClsPub.isLong(txtHProcID.Tag); //获取控件位置 int x = 0; int y = 0; BLL.ClsPub_BLL.SetXY(this, panel4, gbUp, txtHPayProcID, ref x, ref y); //选择基础 BLL.ClsBaseDownSelect.SetTextByProcess(txtHPayProcID, HMainProcID, x, y); //获取NCT冲次单数 //DAL.ClsGy_ProcPrice_Ctl oProcPrice = new DAL.ClsGy_ProcPrice_Ctl(); //txtHUnitChongQty.Text = DBUtility.ClsPub.isDoule(oProcPrice.LoadProcPriceChong(DBUtility.ClsPub.isLong(txtHMaterID.Tag), DBUtility.ClsPub.isLong(txtHPayProcID.Tag), 0), 4); // txtHEmpID.Select(); } } private void txtHPayProcID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHPayProcID); } private void txtHEmpID2_TextChanged(object sender, EventArgs e) { if (txtHEmpID2.Text.Trim() == "") { txtHEmpID2.Tag = 0; txtHEmpName2.Text = ""; } } private void txtHEmpID3_TextChanged(object sender, EventArgs e) { if (txtHEmpID3.Text.Trim() == "") { txtHEmpID3.Tag = 0; txtHEmpName3.Text = ""; } } private void txtHEmpID4_TextChanged(object sender, EventArgs e) { if (txtHEmpID4.Text.Trim() == "") { txtHEmpID4.Tag = 0; txtHEmpName4.Text = ""; } } private void txtHEmpID5_TextChanged(object sender, EventArgs e) { if (txtHEmpID5.Text.Trim() == "") { txtHEmpID5.Tag = 0; txtHEmpName5.Text = ""; } } private void txtHEmpID2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DBUtility.ClsPub.isStrNull(txtHEmpID2.Text) != "") { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHEmpID2.Text))) { txtHEmpID2.Text = oEmp.omodel.HNumber; txtHEmpID2.Tag = oEmp.omodel.HItemID; txtHEmpName2.Text = oEmp.omodel.HName; txtHEmpID3.Focus(); } else { txtHEmpID2.Text = ""; txtHEmpID2.Tag = 0; txtHEmpName2.Text = ""; } } else { txtHEmpID2.Text = ""; txtHEmpID2.Tag = 0; txtHEmpName2.Text = ""; } } } private void txtHEmpID3_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DBUtility.ClsPub.isStrNull(txtHEmpID3.Text) != "") { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHEmpID3.Text))) { txtHEmpID3.Text = oEmp.omodel.HNumber; txtHEmpID3.Tag = oEmp.omodel.HItemID; txtHEmpName3.Text = oEmp.omodel.HName; txtHEmpID4.Focus(); } else { txtHEmpID3.Text = ""; txtHEmpID3.Tag = 0; txtHEmpName3.Text = ""; } } else { txtHEmpID3.Text = ""; txtHEmpID3.Tag = 0; txtHEmpName3.Text = ""; } } } private void txtHEmpID4_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DBUtility.ClsPub.isStrNull(txtHEmpID4.Text) != "") { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHEmpID4.Text))) { txtHEmpID4.Text = oEmp.omodel.HNumber; txtHEmpID4.Tag = oEmp.omodel.HItemID; txtHEmpName4.Text = oEmp.omodel.HName; txtHEmpID5.Focus(); } else { txtHEmpID4.Text = ""; txtHEmpID4.Tag = 0; txtHEmpName4.Text = ""; } } else { txtHEmpID4.Text = ""; txtHEmpID4.Tag = 0; txtHEmpName4.Text = ""; } } } private void txtHEmpID5_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DBUtility.ClsPub.isStrNull(txtHEmpID5.Text) != "") { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHEmpID5.Text))) { txtHEmpID5.Text = oEmp.omodel.HNumber; txtHEmpID5.Tag = oEmp.omodel.HItemID; txtHEmpName5.Text = oEmp.omodel.HName; cmdOK.Focus(); } else { txtHEmpID5.Text = ""; txtHEmpID5.Tag = 0; txtHEmpName5.Text = ""; } } else { txtHEmpID5.Text = ""; txtHEmpID5.Tag = 0; txtHEmpName5.Text = ""; } } } private void cmdHEmpID2_Click(object sender, EventArgs e) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.RefreshView()) { txtHEmpID2.Text = oEmp.oModel.HNumber; txtHEmpID2.Tag = oEmp.oModel.HItemID.ToString(); txtHEmpName2.Text = oEmp.oModel.HName; } else { txtHEmpID2.Text = ""; } } private void cmdHEmpID3_Click(object sender, EventArgs e) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.RefreshView()) { txtHEmpID3.Text = oEmp.oModel.HNumber; txtHEmpID3.Tag = oEmp.oModel.HItemID.ToString(); txtHEmpName3.Text = oEmp.oModel.HName; } else { txtHEmpID3.Text = ""; } } private void cmdHEmpID4_Click(object sender, EventArgs e) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.RefreshView()) { txtHEmpID4.Text = oEmp.oModel.HNumber; txtHEmpID4.Tag = oEmp.oModel.HItemID.ToString(); txtHEmpName4.Text = oEmp.oModel.HName; } else { txtHEmpID4.Text = ""; } } private void cmdHEmpID5_Click(object sender, EventArgs e) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.RefreshView()) { txtHEmpID5.Text = oEmp.oModel.HNumber; txtHEmpID5.Tag = oEmp.oModel.HItemID.ToString(); txtHEmpName5.Text = oEmp.oModel.HName; } else { txtHEmpID5.Text = ""; } } private void cmdDelBill_Click(object sender, EventArgs e) { //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //try //{ // if (MessageBox.Show("确定要删除当前单据对应的入库单?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) // { // //oCn.RunProc(" update Sc_StationOutBillMain set HDelBillFlag=5 Where HInterID= " + BillOld.omodel.HInterID.ToString()); // if (BillOld.DelBillProdIn(BillOld.omodel.HInterID, BillOld.omodel.HBillNo)) // { // MessageBox.Show("删除入库单成功!"); // } // else // { // MessageBox.Show("删除入库单失败11!" + Pub_Class.ClsPub.sExeReturnInfo ); // } // return; // } //} //catch (Exception e1) //{ // MessageBox.Show("删除入库单失败!"); //} } private void MES_StationOutBill_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F12) { Sc_ProcExchBilltransRelationQty ofrm = new Sc_ProcExchBilltransRelationQty(); ofrm.keyitem = lngBillKey; ofrm.ShowDialog(); } } private void button1_Click(object sender, EventArgs e) { //审核权限 //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, DBUtility.ClsPub.CurUserName)) //{ // return; //} // Int64 lInterID = 0; lInterID = BillOld.omodel.HInterID; if (lInterID == 0) { MessageBox.Show("单据未保存,不能审核"); return; } DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); //查看是否已审核,关闭,作废 if (oBill.ShowBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HChecker.Trim() != "") { MessageBox.Show("单据已审核!不能再次审核", "提示"); return; } } else { MessageBox.Show("单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } //判断是否已经存在 入库单 //审核 if (oBill.CheckBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo) == true) { MessageBox.Show("审核成功!", "提示"); return; } else { //删除同名 入库单 // MessageBox.Show("审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } } private void button2_Click(object sender, EventArgs e) { //审核权限 //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, DBUtility.ClsPub.CurUserName)) //{ // return; //} // Int64 lInterID = 0; lInterID = BillOld.omodel.HInterID; if (lInterID == 0) { MessageBox.Show("单据未保存,不能反审核"); return; } DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); //查看是否已审核,关闭,作废 if (oBill.ShowBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HChecker.Trim() == "") { MessageBox.Show("单据未审核!不需要反审核!", "提示"); return; } } else { MessageBox.Show("单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } //反审核 if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { MessageBox.Show("反审核成功!", "提示"); return; } else { MessageBox.Show("反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } } private void txtHWWWorkOrderBillNo_KeyDown(object sender, KeyEventArgs e) { //if (e.KeyCode == Keys.Return) //{ // //如果 没有扫描 及 流水号 则 报错 // if (lngBillKey == 0 || lngBillSubKey == 0) // { // MessageBox.Show("没有录入流转卡号或者流水号"); // return; // } // //根据工号获取委外工单 及内码,子内码 // SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); // DataSet ds; // ds = oCn.RunProcReturn("exec h_p_WW_GetWWWorkBillInfoByNo '" + txtHWWWorkOrderBillNo.Text + "'," + lngBillKey.ToString() + "," + lngBillSubKey.ToString(), "h_p_WW_GetWWWorkBillInfoByNo"); // if (ds == null) // { // MessageBox.Show("没有找到对应的委外工单!"); // return; // } // if (ds.Tables[0].Rows.Count > 0) // { // txtHWWWorkOrderBillNo.Text = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]); // lngBillKey_WW = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HInterID"]); // lngBillSubKey_WW = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HEntryID"]); // txtHWWWorkOrderBillNo.Enabled = false; // } //} } private void txtHDSQty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //txtHWasterQty.Select(); cmdOK.Focus(); //txtHDSQty.Focus(); } } private void txtHQty_TextChanged(object sender, EventArgs e) { txtHChongQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isLong(txtHQty.Text) * DBUtility.ClsPub.isDoule(txtHUnitChongQty.Text), 4); } private void txtHBarCode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Return) { if (txtHBarCode.Text.Trim() == "") { MessageBox.Show("工序流转卡卡号,不能为空!"); return; } DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //拆分条形码 string sBillBarCode = txtHBarCode.Text.Trim(); string[] NewBarCode; if (sBillBarCode.CompareTo("#") > 0) { NewBarCode = sBillBarCode.Split(Convert.ToChar("#")); sBillBarCode = NewBarCode[0]; } string sBillNo = sBillBarCode; //======================================== //得到信息 Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "'", "h_v_Sc_ProcessExchangeBillList"); //写入信息 if (Ds == null || Ds.Tables[0].Rows.Count == 0) { txtHProcExchBillNo.Text = ""; MessageBox.Show("未查询到流转卡信息!"); return; } for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { Sub_WriteInForm_SM(Ds.Tables[0], i); } //Sub_ShowBill(); txtHProcNo.Focus(); txtHProcExchBillNo.Enabled = false; txtHBarCode.Enabled = false; } } private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e) { } GridppReport Report; private void cmdHPrint_Click(object sender, EventArgs e) { //选择打印模板 BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp(); oFrm.sBillName = ModName; oFrm.sBillModel = ModCaption; oFrm.ShowDialog(); if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK) { Sub_SetReport(oFrm.sOpenTmp); Report.PrintPreview(false); Thread.Sleep(1000); } } private void Sub_SetReport(string sOpenTmp) { //判断行数 for (int i = 0; i < grdSub.Rows.Count; i++) { grdSub.Rows[i].Cells[0].Value = "*"; } // Report = new GridppReport(); Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord); Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); } //填入单据表头信息 private void ReportBeforePostRecord()// { try { Report.FieldByName("物料代码").AsString = ClsPub.isStrNull(txtHMaterID.Text); Report.FieldByName("物料名称").AsString = ClsPub.isStrNull(txtHMaterName.Text); Report.FieldByName("规格型号").AsString = ClsPub.isStrNull(txtHMaterModel.Text); ////Report.FieldByName("自定义规格").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HModel2Col].Value); //Report.FieldByName("条码编号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HTMCol].Value); //Report.FieldByName("数量").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HQty2Col].Value); //Report.FieldByName("源单单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); //Report.FieldByName("销售订单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value); //Report.FieldByName("生产车间").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value); //Report.FieldByName("备注").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value); } catch (Exception e) { MessageBox.Show("打印失败!表头:" + e.Message); } } private void ReportFetchRecordByDataTable() { try { DataTable ds = new DataTable(); BLL.Utility.FillRecordToReport_Sel(Report, grdSub, ds, 0); } catch (Exception e) { MessageBox.Show("打印失败!表体:" + e.Message); } } private void cmdHPrintCusCard_Click(object sender, EventArgs e) { //选择打印模板 BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp(); oFrm.sBillName = ModName; oFrm.sBillModel = ModCaption; oFrm.ShowDialog(); if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK) { Sub_SetReportCusCard(oFrm.sOpenTmp); Report.PrintPreview(false); Thread.Sleep(1000); } } private void Sub_SetReportCusCard(string sOpenTmp) { //判断行数 for (int i = 0; i < grdSub.Rows.Count; i++) { grdSub.Rows[i].Cells[0].Value = "*"; } // Report = new GridppReport(); Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecordCusCard); Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTableCusCard); } //填入单据表头信息 private void ReportBeforePostRecordCusCard()// { try { Report.FieldByName("物料代码").AsString = ClsPub.isStrNull(txtHMaterID.Text); Report.FieldByName("物料名称").AsString = ClsPub.isStrNull(txtHMaterName.Text); Report.FieldByName("规格型号").AsString = ClsPub.isStrNull(txtHMaterModel.Text); ////Report.FieldByName("自定义规格").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HModel2Col].Value); //Report.FieldByName("条码编号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HTMCol].Value); //Report.FieldByName("数量").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HQty2Col].Value); //Report.FieldByName("源单单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); //Report.FieldByName("销售订单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value); //Report.FieldByName("生产车间").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value); //Report.FieldByName("备注").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value); } catch (Exception e) { MessageBox.Show("打印失败!表头:" + e.Message); } } private void ReportFetchRecordByDataTableCusCard() { try { DataTable ds = new DataTable(); BLL.Utility.FillRecordToReport_Sel(Report, grdSub, ds, 0); } catch (Exception e) { MessageBox.Show("打印失败!表体:" + e.Message); } } private void label39_Click(object sender, EventArgs e) { } private void txtHQCCheckID_TextChanged(object sender, EventArgs e) { if (txtHQCCheckID.Text.Trim() == "") { txtHQCCheckID.Tag = 0; txtHQCCheckName.Text = ""; } } private void txtHQCCheckID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DBUtility.ClsPub.isStrNull(txtHQCCheckID.Text) != "") { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHQCCheckID.Text))) { txtHQCCheckID.Text = oEmp.omodel.HNumber; txtHQCCheckID.Tag = oEmp.omodel.HItemID; txtHQCCheckName.Text = oEmp.omodel.HName; } else { txtHQCCheckID.Text = ""; txtHQCCheckID.Tag = 0; txtHQCCheckName.Text = ""; } } else { txtHQCCheckID.Text = ""; txtHQCCheckID.Tag = 0; txtHQCCheckName.Text = ""; } txtHBadCount.Focus(); } } private void cmdHQCCheckID_Click(object sender, EventArgs e) { DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); if (oEmp.RefreshView()) { txtHQCCheckID.Text = oEmp.oModel.HNumber; txtHQCCheckID.Tag = oEmp.oModel.HItemID.ToString(); txtHQCCheckName.Text = oEmp.oModel.HName; } else { txtHQCCheckID.Text = ""; } } private void cmdHSourceID2_Click(object sender, EventArgs e) { DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); if (oSource.RefreshView()) { txtHSourceID2.Text = oSource.oModel.HNumber; txtHSourceID2.Tag = oSource.oModel.HItemID.ToString(); txtHSourceName2.Text = oSource.oModel.HName; } else { txtHSourceID2.Text = ""; txtHSourceName2.Text = ""; } } private void cmdHSourceID3_Click(object sender, EventArgs e) { DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); if (oSource.RefreshView()) { txtHSourceID3.Text = oSource.oModel.HNumber; txtHSourceID3.Tag = oSource.oModel.HItemID.ToString(); txtHSourceName3.Text = oSource.oModel.HName; } else { txtHSourceID3.Text = ""; txtHSourceName3.Text = ""; } } private void cmdHSourceID4_Click(object sender, EventArgs e) { DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); if (oSource.RefreshView()) { txtHSourceID4.Text = oSource.oModel.HNumber; txtHSourceID4.Tag = oSource.oModel.HItemID.ToString(); txtHSourceName4.Text = oSource.oModel.HName; } else { txtHSourceID4.Text = ""; txtHSourceName4.Text = ""; } } private void cmdHSourceID5_Click(object sender, EventArgs e) { DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); if (oSource.RefreshView()) { txtHSourceID5.Text = oSource.oModel.HNumber; txtHSourceID5.Tag = oSource.oModel.HItemID.ToString(); txtHSourceName5.Text = oSource.oModel.HName; } else { txtHSourceID5.Text = ""; txtHSourceName5.Text = ""; } } private void txtHQty_KeyPress(object sender, KeyPressEventArgs e) { VailInt(sender, e); } /// /// 限制文本框只能输入正整数 /// /// /// public void VailInt(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件 } else if (Char.IsPunctuation(e.KeyChar)) { e.Handled = true; } } private void txtHWasterQty_KeyPress(object sender, KeyPressEventArgs e) { VailInt(sender, e); } //新增 private void cmdXZ_Click(object sender, EventArgs e) { this.Sub_AddBill(); } private void label26_Click(object sender, EventArgs e) { } private void txtHMouldNum_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHGroupID.Focus(); } } private void txtHBadCount_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHWorkTimes.Focus(); } } private void txtHWorkTimes_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHWasterQty.Focus(); } } } }