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; namespace WorkM { public partial class MES_StationEntrustOutBill : Form { public MES_StationEntrustOutBill() { InitializeComponent(); } public bool sTextChanged = true; //下拉框 ComboBox cmb = new ComboBox();  //这里实例化一个ComboBox控件  Rectangle _Rectangle; //定义列 public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HMaterNumberCol = 2; public const Int16 HMaterNameCol = 3; public const Int16 HMaterModelCol = 4; public const Int16 HUnitNameCol = 5; public const Int16 HWhNameCol = 6; public const Int16 HQtyCol = 7; public const Int16 HRemarkCol = 8; public const Int16 HOrderProcNoCol = 9; // // //表2 public const Int16 SecHTagCol = 0; public const Int16 SecHSnoCol = 1; public const Int16 SecHTypeCol = 2; public const Int16 SecHProcNoCol = 3; public const Int16 SecHTechParamIDCol = 4; public const Int16 SecHTechParamNumberCol = 5; public const Int16 SecHTechParamNameCol = 6; public const Int16 SecHStdCol = 7; public const Int16 SecHValueCol = 8; public const Int16 SecHTechParamUnitIDCol = 9; public const Int16 SecHTechParamUnitNumberCol = 10; public const Int16 SecHTechParamUnitNameCol = 11; public const Int16 SecHEntryIDCol = 12; public string ModName = "3793"; public string ModCaption = "委外工序接收"; public const string ModRightName = "MES_StationEntrustOutBill"; public const string ModRightNameEdit = ModRightName + "_Edit"; public const string ModRightNameDelete = ModRightName + "_Delete"; public const string ModRightNameMoney = ModRightName + "_Money"; public bool BillChange; // public DBUtility.ClsPub.Enum_BillStatus BillStatus; public Int64 KeyID; public bool grdStatus; public DAL.ClsSc_StationEntrustOutBill BillNew = new DAL.ClsSc_StationEntrustOutBill(); public DAL.ClsSc_StationEntrustOutBill BillOld = new DAL.ClsSc_StationEntrustOutBill(); ClsGridViewSum oSumGrid = new ClsGridViewSum(); ClsGridViewSum oSumGrid_Sub = new ClsGridViewSum(); public Int64 lngBillKey; //流转卡ID public Int64 lngBillSubKey; //流转卡子ID public Int64 lngBillKey_WW; public Int64 lngBillSubKey_WW = -1; long sHMainSourceInterID; //进站单ID string sHMainSourceBillNo; //进站单号 //------------------------------------------------------------------------- #region 固定代码 //清空界面 public void Sub_ClearBill() { DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp); //DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp2); txtHBarCode.Focus(); txtHTaxRate.Text = "16"; initGrid(); initGrid_Sub(); } //出站按钮 private void cmdOK_Click(object sender, EventArgs e) { this.Sub_SaveBill(); cmdCancel.Focus(); //DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); //DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "1"); } //取消按钮 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; } } //DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); //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_StationEntrustOutBill_Load(object sender, EventArgs e) { //打印初始化 oSumGrid.NoCol = HSnoCol; oSumGrid.ogrdMain = grdMain; oSumGrid.oGridsum = grdSum; // this.Text = ModCaption; //命名窗体标题 this.lblCaption.Text = ModCaption;//命名单据标题 //判断金额权限 if (!ClsPub.Security_Log(ModRightNameMoney, 1, false, DBUtility.ClsPub.CurUserName)) { txtHPrice.Visible = false; txtHMoney.Visible = false; label18.Visible = false; //单价 label19.Visible = false; //金额 txtHRemark.Visible = false; label22.Visible = false; //备注 label24.Visible = false; //不含税金额 label25.Visible = false; //不含税单价 txtHPrice_BHS.Visible = false; txtHMoney_BHS.Visible = false; } } //窗体尺寸变化时 private void Sc_StationEntrustOutBill_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_StationEntrustOutBill_FormClosing(object sender, FormClosingEventArgs e) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; //DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } //新增单据 private void Sub_AddBill() { this.BillNew = new DAL.ClsSc_StationEntrustOutBill(); this.BillOld = new DAL.ClsSc_StationEntrustOutBill(); 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);//得到新单号 if (lngBillKey != 0 ) { LotShow(); } } private void LotShow() { //DataSet Ds; //DataSet DsGY; //DataSet DsJG; //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); ////Ds = oCn.RunProcReturn("Select * from h_v_MES_NowWorkBillList Where hmainid=" + lngBillKey + "and hsubid=" + lngBillSubKey, "h_v_MES_NowWorkBillList", ref DBUtility.ClsPub.sErrInfo); ////Ds = oCn.RunProcReturn("exec h_p_MES_NowWorkBillList " + lngBillKey + "," + lngBillSubKey, "h_p_MES_NowWorkBillList", ref DBUtility.ClsPub.sErrInfo); //Ds = oCn.RunProcReturn("exec h_p_Sc_GetProcByLotNo " + lngBillKey, "h_p_Sc_GetProcByLotNo"); //if (Ds == null) //{ // MessageBox.Show("错误原因:" + DBUtility.ClsPub.sErrInfo); // return; //} //if (Ds.Tables[0].Rows.Count == 0) //{ // MessageBox.Show("LOT卡无效!"); // return; //} //if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "out" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "自制") //{ // MessageBox.Show("该LOT卡下道工序为自制出站!"); // return; //} //else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "in" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "委外") //{ // MessageBox.Show("该LOT卡下道工序为委外发出!"); // return; //} //else if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInorOut"]) == "in" && DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]) == "自制") //{ // MessageBox.Show("该LOT卡下道工序为自制进站!"); // return; //} //lngBillSubKey = ClsPub.isLong(Ds.Tables[0].Rows[0]["HSubID"]); //txtHICMOBillNo.Tag = ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]); //txtHICMOBillNo.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["任务单号"]); //txtHProcExchBillNo.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["单据号"]); //txtHProcID.Tag = ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]); //txtHProcID.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["工序"]); //txtHMaterID.Tag = ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]); //txtHMaterID.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["产品代码"]); //txtHMaterName.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["产品"]); //txtHMaterModel.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["规格型号"]); ////txtHSourceID.Tag = ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]); ////txtHSourceID.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["生产资源"]); ////txtHGroupID.Tag = ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]); ////txtHGroupID.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["班组"]); ////txtHEmpID.Tag = ClsPub.isLong(Ds.Tables[0].Rows[0]["HWorkerID"]); ////txtHEmpID.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["操作工"]); //txtHICMOQty.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["任务单数量"]); //txtHPlanQty.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["计划数量"]); //txtHQty.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["计划数量"]); //txtHPlanPieceQty.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["板数"]); //txtHPieceQty.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["板数"]); //txtHSupID.Tag = ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]); //txtHSupID.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["供应商"]); //sHMainSourceInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HJZInterID"]); //sHMainSourceBillNo = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HJZBillNo"]); //txtHTaxRate.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["税率"]); //txtHPrice.Text = ClsPub.isStrNull(ClsPub.isDoule(Ds.Tables[0].Rows[0]["单价"],6)); //txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule(ClsPub.isDoule(Ds.Tables[0].Rows[0]["板数"]) * ClsPub.isDoule( ClsPub.isDoule(Ds.Tables[0].Rows[0]["单价"],6)), 4)); //txtHPrice_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(ClsPub.isDoule(txtHPrice.Text) / (ClsPub.isDoule(txtHTaxRate.Text)/100+1), 6)); //txtHMoney_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(ClsPub.isDoule(txtHMoney.Text) / (ClsPub.isDoule(txtHTaxRate.Text)/100+1), 4)); //txtHRemark.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]); //txtHInnerBillNo.Text = ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]); //initGrid(); //initGrid_Sub(); //for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) //{ // if (i >= grdMain.RowCount - 1) // { // grdMain.Rows.Add(); // } // grdMain.Rows[i].Cells[HTagCol].Value = "*"; // grdMain.Rows[i].Cells[HProcNoCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HProcNo"]); // grdMain.Rows[i].Cells[HProcIDCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HProcID"]); // grdMain.Rows[i].Cells[HProcNumberCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["工序代码"]); // grdMain.Rows[i].Cells[HProcNameCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["工序"]); // grdMain.Rows[i].Cells[HQtyCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["计划数量"]); // grdMain.Rows[i].Cells[HEntryIDCol].Value = i + 1; // grdMain.Rows[i].Cells[HProcExchEntryIDCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["hsubid"]); // DsGY = oCn.RunProcReturn("exec h_p_Sc_GetTechParamByProc " + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcID"]), "h_p_Sc_GetTechParamByProc"); // //明细类赋值 // for (int j = 0; j < DsGY.Tables[0].Rows.Count; j++) // { // Model.ClsSc_StationEntrustOutBillSub_Item oSub = new Model.ClsSc_StationEntrustOutBillSub_Item(); // oSub.HEntryID = i + 1; // oSub.HProcNo = ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcNo"]); // oSub.HTechParamID = ClsPub.isLong(DsGY.Tables[0].Rows[j]["HTechParamID"]); // oSub.HTechParamUnitID = ClsPub.isLong(DsGY.Tables[0].Rows[j]["HTechParamUnitID"]); // oSub.HValue = ""; // oSub.HStd = ""; // oSub.HType = ClsPub.isStrNull(DsGY.Tables[0].Rows[j]["HType"]); // BillOld.DetailColl1.Add(oSub); // } //} ////DsJG = oCn.RunProcReturn("exec h_p_MES_GetSupPrice " + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]) //// + " ," + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]) //// + " ," + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]), "h_p_MES_GetSupPrice"); ////if (DsJG == null) ////{ //// MessageBox.Show("获取单价失败!", "提示"); //// return; ////} ////if (DsJG.Tables[0].Rows.Count == 0) ////{ //// txtHPrice.Text = "0"; //// txtHMoney.Text = "0"; //// txtHRemark.Text = ""; ////} ////else ////{ //// txtHPrice.Text = DsJG.Tables[0].Rows[0][0].ToString(); //// txtHMoney.Text = ClsPub.isStrNull(DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["板数"]) * DBUtility.ClsPub.isDoule(DsJG.Tables[0].Rows[0][0].ToString())); //// txtHRemark.Text = DsJG.Tables[0].Rows[0][1].ToString(); ////} } //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; 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; 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; Sub_LrtextStatus(true); break; } } //根据编辑状态 设置 控件是否允许录入 private void Sub_LrtextStatus(bool TextEnabled) { if (TextEnabled == true) { //控件全部有效 gbUp.Enabled = true; //gbUp2.Enabled = true; } else { //控件全部无效 gbUp.Enabled = false; //gbUp2.Enabled = false; } } #endregion #region 读写类 //显示单据 public void Sub_ShowBill() { sTextChanged = false; 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.ClsIF_Supplier_View oSup = new DAL.ClsIF_Supplier_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; } //清空 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 (oSup.GetInfoByID(BillOld.omodel.HSupID)) { this.txtHSupID.Text = oSup.omodel.HName; this.txtHSupID.Tag = oSup.omodel.HItemID.ToString(); } else { this.txtHSupID.Text = ""; } // if (oEmp.GetInfoByID(BillOld.omodel.HEmpID)) { this.txtHEmpID.Text = oEmp.omodel.HName; this.txtHEmpID.Tag = oEmp.omodel.HItemID.ToString(); } else { this.txtHEmpID.Text = ""; } // if (oSource.GetInfoByID(BillOld.omodel.HSourceID)) { this.txtHSourceID.Text = oSource.omodel.HName; this.txtHSourceID.Tag = oSource.omodel.HItemID.ToString(); } else { this.txtHSourceID.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 (oGroup.GetInfoByID(BillOld.omodel.HGroupID)) { this.txtHGroupID.Text = oGroup.omodel.HName; this.txtHGroupID.Tag = oGroup.omodel.HItemID.ToString(); } else { this.txtHGroupID.Text = ""; } // this.txtHBillNo.Text = BillOld.omodel.HBillNo; this.txtHInnerBillNo.Text = BillOld.omodel.HInnerBillNo; this.txtHICMOBillNo.Text = BillOld.omodel.HICMOBillNo; this.txtHICMOBillNo.Tag = BillOld.omodel.HICMOInterID; lngBillKey = BillOld.omodel.HProcExchInterID; lngBillSubKey = BillOld.omodel.HProcExchEntryID; lngBillKey_WW = BillOld.omodel.HWWWorkOrderInterID; lngBillSubKey_WW = BillOld.omodel.HWWWorkOrderEntryID; this.txtHWWWorkOrderBillNo.Text = BillOld.omodel.HWWWorkOrderBillNo; 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.txtHBadPNL.Text = BillOld.omodel.HBadPNL.ToString(); this.txtHRemark.Text = BillOld.omodel.HRemark.ToString(); this.txtHWasterQty.Text = BillOld.omodel.HWasterQty.ToString(); this.txtHQty.Text = BillOld.omodel.HQty.ToString(); this.txtHPieceQty.Text = BillOld.omodel.HPieceQty.ToString(); this.txtHPlanPieceQty.Text = BillOld.omodel.HPlanPieceQty.ToString(); this.txtHPrice.Text = BillOld.omodel.HPrice.ToString(); this.txtHMoney.Text = BillOld.omodel.HMoney.ToString(); this.txtHProcNO.Text = BillOld.omodel.HProcNo.ToString(); this.txtHPrice_BHS.Text = BillOld.omodel.HPrice_BHS.ToString(); this.txtHMoney_BHS.Text = BillOld.omodel.HMoney_BHS.ToString(); this.txtHTaxRate.Text = BillOld.omodel.HTaxRate.ToString(); this.txtHOrderProcNO.Text = BillOld.omodel.HOrderProcNO.ToString(); sHMainSourceInterID = BillOld.omodel.HMainSourceInterID; sHMainSourceBillNo = BillOld.omodel.HMainSourceBillNo; //加载表体 initGrid(); //initGrid_Sub(); //根据送货单号 获取 全部该送货单号的记录 并打印 //if (txtHInnerBillNo.Text.Trim() != "") //{ // SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); // DataSet ds = oCn.RunProcReturn("exec h_p_MES_StationEntrustOutBillPrint_Add '" + txtHInnerBillNo.Text.Trim() + "'," + txtHSupID.Tag + "", "h_p_MES_StationEntrustOutBillPrint"); // if (ds == null || ds.Tables[0].Rows.Count == 0) // { // } // else // { // for (int i = 0; i < ds.Tables[0].Rows.Count; i++) // { // if (i >= grdMain.RowCount - 1) // { // grdMain.Rows.Add(); // } // //单据固定赋值 // grdMain.Rows[i].Cells[HTagCol].Value = "*"; // grdMain.Rows[i].Cells[HSnoCol].Value = i + 1; // grdMain.Rows[i].Cells[HMaterNumberCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HMaterNumber"]); // grdMain.Rows[i].Cells[HMaterNameCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HMaterName"]); // grdMain.Rows[i].Cells[HMaterModelCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HMaterModel"]); // grdMain.Rows[i].Cells[HUnitNameCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HUnitName"]); // grdMain.Rows[i].Cells[HWhNameCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HWHName"]); // grdMain.Rows[i].Cells[HQtyCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HQTY"]); // grdMain.Rows[i].Cells[HRemarkCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]); // grdMain.Rows[i].Cells[HOrderProcNoCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HOrderProcNo"]); // } // } //} //====================================================================================== // Sub_OperStatus(); sTextChanged = true; txtHProcExchBillNo.Enabled = false; txtHProcNO.Enabled = false; } //单据完整性判断 未完成 private bool Sub_AllowSave() { //判断该用户名是否有该工站权限 //if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(66865)) == 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; // } //} ////判断参数内容是否存在空的数据 //foreach (Model.ClsSc_StationEntrustOutBillSub_Item oSub in BillOld.DetailColl1) //{ // if (oSub.HValue == "") // { // MessageBox.Show("实际参数值不允许存在空行,如实际情况为空,请输入 '/ ' ", "提示"); // return false; // } // if (oSub.HStd == "" && oSub.HType == "首件") // { // MessageBox.Show("首件标准参数值不允许存在空行,如实际情况为空,请输入 '/ ' ", "提示"); // return false; // } //} //必输项目是否为空 //if (DBUtility.ClsPub.isLong(lngBillKey_WW) <= 0) //{ // MessageBox.Show("委外工单号没有选择!", "提示"); // return false; //} //if (DBUtility.ClsPub.isLong(lngBillSubKey_WW) < 0) //{ // MessageBox.Show("委外工单号没有选择2!", "提示"); // 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.isStrNull(txtHInnerBillNo.Text) == "") { MessageBox.Show("发货号没有输入!", "提示"); return false; } if (DBUtility.ClsPub.isLong(txtHProcID.Tag) == 0) { 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(txtHSupID.Tag) == 0) { MessageBox.Show("供应商没有选择!", "提示"); return false; } //if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0) //{ // MessageBox.Show("操作员没有选择!", "提示"); // return false; //} //if (DBUtility.ClsPub.isLong(txtHSourceID.Tag) == 0) //{ // MessageBox.Show("生产资源没有选择!", "提示"); // return false; //} //if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim())==0 && DBUtility.ClsPub.isDoule(txtHPieceQty.Text.Trim()) == 0.0) //{ // MessageBox.Show("接收个数不能为0!", "提示"); // return false; //} if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) + DBUtility.ClsPub.isDoule(txtHWasterQty.Text.Trim()) <= 0) { MessageBox.Show("接收个数不能为0!", "提示"); return false; } if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) < 0) { MessageBox.Show("接收个数不能小于0!", "提示"); return false; } //if (DBUtility.ClsPub.isDoule(txtHQty.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanQty.Text.Trim())) //{ // MessageBox.Show("接收数量不能大于计划数量!", "提示"); // return false; //} if (DBUtility.ClsPub.isDoule(txtHWasterQty.Text.Trim()) < 0) { MessageBox.Show("不合格数不能小于0!", "提示"); return false; } //if (DBUtility.ClsPub.isDoule(txtHWasterQty.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanQty.Text.Trim())) //{ // MessageBox.Show("不合格数不能大于计划数量!", "提示"); // return false; //} if (DBUtility.ClsPub.isDoule(txtHTaxRate.Text.Trim()) < 0) { MessageBox.Show("税率不能为负!", "提示"); return false; } //if (DBUtility.ClsPub.isDoule(txtHPrice.Text) == 0) //{ // MessageBox.Show("含税单价不能为0!", "提示"); // 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数!", "提示"); // return false; //} //if (DBUtility.ClsPub.isDoule(txtHPieceQty.Text.Trim()) > DBUtility.ClsPub.isDoule(txtHPlanPieceQty.Text.Trim())) //{ // MessageBox.Show("接收件数不能大于发出件数!", "提示"); // 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; } return true; } //保存单据 private bool Sub_SaveBill() { Model.ClsSc_StationEntrustOutBillSub oBillSub = new Model.ClsSc_StationEntrustOutBillSub(); //判断权限 if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName)) { return false; } // bool bResult; BillNew = new DAL.ClsSc_StationEntrustOutBill(); //失去焦点 lblCaption.Focus(); //SaveSub();//保存参数表信息 if (!Sub_AllowSave())//单据完整性判断 return false; //赋值ID if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify) BillNew.omodel.HInterID = BillOld.omodel.HInterID; //主类赋值 BillNew.omodel.HYear = 2011; BillNew.omodel.HPeriod = 1; BillNew.omodel.HBillNo = this.txtHBillNo.Text.Trim(); BillNew.omodel.HInnerBillNo = this.txtHInnerBillNo.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.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.HSourceID = DBUtility.ClsPub.isLong(this.txtHSourceID.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.HQty = DBUtility.ClsPub.isDoule(this.txtHQty.Text); BillNew.omodel.HSupID = DBUtility.ClsPub.isLong(this.txtHSupID.Tag); BillNew.omodel.HPieceQty = DBUtility.ClsPub.isDoule(this.txtHPieceQty.Text); BillNew.omodel.HPlanPieceQty = DBUtility.ClsPub.isDoule(this.txtHPlanPieceQty.Text); BillNew.omodel.HPrice = ClsPub.isDoule(DBUtility.ClsPub.isDoule(this.txtHPrice.Text,6)); BillNew.omodel.HMoney = ClsPub.isDoule(DBUtility.ClsPub.isDoule(this.txtHMoney.Text,4)); BillNew.omodel.HProcNo = DBUtility.ClsPub.isLong(this.txtHProcNO.Text); BillNew.omodel.HPrice_BHS = ClsPub.isDoule(DBUtility.ClsPub.isDoule(this.txtHPrice_BHS.Text,6)); BillNew.omodel.HMoney_BHS = ClsPub.isDoule(DBUtility.ClsPub.isDoule(this.txtHMoney_BHS.Text, 4)); BillNew.omodel.HTaxRate = DBUtility.ClsPub.isDoule(this.txtHTaxRate.Text); //BillNew.omodel.HOrderProcNO = this.txtHOrderProcNO.Text.Trim(); BillNew.omodel.HOrderProcNO = DBUtility.ClsPub.isStrNull(this.txtHOrderProcNO.Text); BillNew.omodel.HBadPNL = DBUtility.ClsPub.isDoule(this.txtHBadPNL.Text); BillNew.omodel.HWasterQty = DBUtility.ClsPub.isDoule(this.txtHWasterQty.Text); BillNew.omodel.HRemark = DBUtility.ClsPub.isStrNull(this.txtHRemark.Text); BillNew.omodel.HLastSubProc = true; BillNew.omodel.HMainSourceInterID = sHMainSourceInterID; BillNew.omodel.HMainSourceBillNo = sHMainSourceBillNo; BillNew.omodel.HMainSourceBillType = "3792"; BillNew.omodel.HWWWorkOrderInterID = lngBillKey_WW; BillNew.omodel.HWWWorkOrderEntryID = lngBillSubKey_WW; BillNew.omodel.HWWWorkOrderBillNo = DBUtility.ClsPub.isStrNull(this.txtHWWWorkOrderBillNo.Text); //明细类赋值 //BillNew.DetailColl = new List(); //for (int i = 0; i <= grdMain.RowCount - 1; i++) //{ // if (ClsPub.isLong(grdMain.Rows[i].Cells[HProcIDCol].Value) != 0) // { // Model.ClsSc_StationEntrustOutBillSub oSub = new Model.ClsSc_StationEntrustOutBillSub(); // //固定赋值======================================== // oSub.HEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HEntryIDCol].Value); // oSub.HRemark = ""; // oSub.HSourceInterID = lngBillKey; // oSub.HSourceEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HProcExchEntryIDCol].Value); // 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 = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HProcIDCol].Value); // oSub.HProcNo = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HProcNoCol].Value); // oSub.HMaterID = DBUtility.ClsPub.isLong(this.txtHMaterID.Tag); // oSub.HEmpID = DBUtility.ClsPub.isLong(this.txtHEmpID.Tag); // oSub.HSourceID = DBUtility.ClsPub.isLong(this.txtHSourceID.Tag); // oSub.HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HQtyCol].Value); // oSub.HPieceQty = DBUtility.ClsPub.isDoule(this.txtHPieceQty.Text); // oSub.HSourceName = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSourceNameCol].Value); // oSub.HBillNo_bak = BillNew.omodel.HBillNo; // oSub.HProcExchInterID = lngBillKey; // oSub.HProcExchEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HProcExchEntryIDCol].Value); // 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(), "提示"); 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() { // grdMain.ColumnCount = 10; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name); //= grdMain.Columns[HSnoCol].HeaderText = "序号"; grdMain.Columns[HRemarkCol].HeaderText = "表体备注"; grdMain.Columns[HMaterNumberCol].HeaderText = "物料代码"; grdMain.Columns[HMaterNameCol].HeaderText = "物料名称"; grdMain.Columns[HMaterModelCol].HeaderText = "规格型号"; grdMain.Columns[HUnitNameCol].HeaderText = "计量单位名称"; grdMain.Columns[HQtyCol].HeaderText = "数量"; grdMain.Columns[HWhNameCol].HeaderText = "仓库名称"; grdMain.Columns[HOrderProcNoCol].HeaderText = "订单跟踪号"; ////固定赋值===================================================== //============================================================================= //格式化 ////隐藏列 grdMain.Columns[HTagCol].Visible = false; //设置可编辑列 //HQtyCol.ToString() + // "," + string sAllowCol = ""; //设置合计列 string sTotalCol = ""; //格式化网格 DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); oSumGrid.SetGridMain(); //得到对应源单信息 } //初始化GRID Sub private void initGrid_Sub() { //grdSub.RowCount = 0; //grdSub.ColumnCount = 13; //总列数 //DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name + "1"); ////= //grdSub.Columns[SecHProcNoCol].HeaderText = "工序号"; //grdSub.Columns[SecHTypeCol].HeaderText = "参数类型"; //grdSub.Columns[SecHTechParamIDCol].HeaderText = "参数ID"; //grdSub.Columns[SecHTechParamNumberCol].HeaderText = "参数代码"; //grdSub.Columns[SecHTechParamNameCol].HeaderText = "参数名称"; //grdSub.Columns[SecHTechParamUnitIDCol].HeaderText = "参数单位ID"; //grdSub.Columns[SecHTechParamUnitNumberCol].HeaderText = "参数单位代码"; //grdSub.Columns[SecHTechParamUnitNameCol].HeaderText = "参数单位名称"; //grdSub.Columns[SecHValueCol].HeaderText = "实际参数值"; //grdSub.Columns[SecHStdCol].HeaderText = "标准参数值"; //////固定赋值===================================================== //grdSub.Columns[SecHSnoCol].HeaderText = "序号"; ////============================================================================= ////下拉框 //grdSub.Controls.Add(cmb);  //把下拉框控件加入DataGridView  //cmb.Visible = false;  //先不让它显示  //cmb.DropDownStyle = ComboBoxStyle.DropDownList;//设置格式为不可编辑 //cmb.Items.Clear(); //cmb.Items.Add("首件"); //cmb.Items.Add("工艺"); //cmb.Items.Add("辅材"); //cmb.SelectedIndexChanged += new EventHandler(cmb_TextChange); //为下拉框控件加入事件cmb_TextChange  ////格式化 //////隐藏列 //grdSub.Columns[SecHTagCol].Visible = false; //grdSub.Columns[SecHTechParamIDCol].Visible = false; //grdSub.Columns[SecHTechParamUnitIDCol].Visible = false; //grdSub.Columns[SecHTechParamNumberCol].Visible = false; //grdSub.Columns[SecHTechParamUnitNumberCol].Visible = false; //grdSub.Columns[SecHEntryIDCol].Visible = false; ////设置可编辑列 //string sAllowCol = SecHValueCol.ToString() + // "," + SecHStdCol.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) { if (!grdStatus) { return; } oSumGrid.EditStatus = true; switch (sKeyCode) { case 118: //F7 { switch (sCol) { case SecHTechParamNumberCol: //BLL.ClsBaseSelect.SetGridByTech(grdSub, sRow, SecHTechParamIDCol, SecHTechParamNumberCol, SecHTechParamNameCol); //grdSub.Rows[sRow].Cells[SecHProcNoCol].Value = grdMain.Rows[grdMain.CurrentRow.Index].Cells[HProcNoCol].Value; //grdSub.Rows[sRow].Cells[SecHEntryIDCol].Value = grdMain.Rows[grdMain.CurrentRow.Index].Cells[HEntryIDCol].Value; //oEdit.Text = DBUtility.ClsPub.isStrNull(grdSub.Rows[sRow].Cells[SecHTechParamNumberCol].Value); break; case SecHTechParamUnitNumberCol: //BLL.ClsBaseSelect.SetGridByTechU(grdSub, sRow, SecHTechParamUnitIDCol, SecHTechParamUnitNumberCol, SecHTechParamUnitNameCol); //oEdit.Text = DBUtility.ClsPub.isStrNull(grdSub.Rows[sRow].Cells[SecHTechParamUnitNumberCol].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) { BLL.ClsBaseSelect.SetTextByEmp(txtHEmpID); } private void txtHEmpID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHEmpID); } 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.HName; txtHSourceID.Tag = oSource.oModel.HItemID.ToString(); } else { txtHSourceID.Text = ""; } } private void txtHSourceID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHSourceID); } private void cmdHProcID_Click(object sender, EventArgs e) { //BLL.ClsBaseSelect.SetTextByProc(txtHProcID); //if (lngBillKey == 0) //{ // MessageBox.Show("请先扫描LOT卡!","提示"); // return; //} //else //{ DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); if (oProc.RefreshView()) { //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); } private void txtHGroupID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHGroupID); } 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; } //if (e.KeyCode == Keys.Enter) //{ // DAL.ClsSc_ProcessExchangeBill oPeb = new DAL.ClsSc_ProcessExchangeBill(); // if (oPeb.GetIDByNo(DBUtility.ClsPub.isStrNull(txtHProcExchBillNo.Text), ref ClsPub.sExeReturnInfo) == false) // { // MessageBox.Show(ClsPub.sExeReturnInfo, "提示"); // lngBillKey = 0; // lngBillSubKey = 0; // txtHProcID.Tag = 0; // txtHProcID.Text = ""; // txtHProcExchBillNo.Text = ""; // return; // } // lngBillKey = oPeb.omodel.HInterID; // lngBillSubKey = 0; // txtHProcID.Tag = 0; // txtHProcID.Text = ""; // LotShow(); //} } //根据TABLE写入界面 private void Sub_WriteInForm_SM(DataTable oTable, int i) { DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View(); // 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); txtHProcExchBillNo.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["单据号"]); txtHICMOQty.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["任务单数量"]); lngBillKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["hmainid"]); lngBillSubKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HSubID"]); this.txtHOrderProcNO.Text = DBUtility.ClsPub.isStrNull(oTable.Rows[0]["订单跟踪号"]); //加载表体 } private void txtHProcID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (lngBillKey == 0) { MessageBox.Show("请先扫描流转卡!", "提示"); return; } if (DBUtility.ClsPub.isStrNull(txtHProcID.Text) != "") { DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); if (oProc.GetInfoByNumber(DBUtility.ClsPub.isStrNull(txtHProcID.Text))) { lngBillSubKey = oProc.omodel.HEntryID; txtHProcID.Text = oProc.omodel.HName; txtHProcID.Tag = oProc.omodel.HItemID; txtHQty.Focus(); 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.HName; txtHEmpID.Tag = oEmp.omodel.HItemID; } else { txtHEmpID.Text = ""; txtHEmpID.Tag = 0; } } else { txtHEmpID.Text = ""; txtHEmpID.Tag = 0; } } } 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.HName; txtHSourceID.Tag = oSource.omodel.HItemID; } else { txtHSourceID.Text = ""; txtHSourceID.Tag = 0; } } else { txtHSourceID.Text = ""; txtHSourceID.Tag = 0; } } } private void txtHGroupID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { 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.HName; txtHGroupID.Tag = oGroup.omodel.HItemID; } else { txtHGroupID.Text = ""; txtHGroupID.Tag = 0; } } else { txtHGroupID.Text = ""; txtHGroupID.Tag = 0; } } } private void cmdAddNew_Click(object sender, EventArgs e) { lngBillKey = 0; lngBillSubKey = 0; Sub_AddBill(); } private void GetgrdSub(long sEntryID) { //DAL.ClsGy_TechnologyParameter_View oTech = new DAL.ClsGy_TechnologyParameter_View(); //DAL.ClsGy_TechnologyParameterUnit_View oTechU = new DAL.ClsGy_TechnologyParameterUnit_View(); //DAL.ClsGy_FirstPieceParameter_View oFirst = new DAL.ClsGy_FirstPieceParameter_View(); //DAL.ClsGy_FirstPieceParameterUnit_View oFirstU = new DAL.ClsGy_FirstPieceParameterUnit_View(); //DAL.ClsGy_Auxiliary_View oAuxiliary = new DAL.ClsGy_Auxiliary_View(); //initGrid_Sub(); //int i = 0; //foreach (Model.ClsSc_StationEntrustOutBillSub_Item oSub in BillOld.DetailColl1) //{ // if (oSub.HEntryID == sEntryID) // { // if (i >= grdSub.RowCount - 1) // grdSub.Rows.Add(); // grdSub.Rows[i].Cells[SecHTagCol].Value = "*"; // if (oSub.HType == "工艺") // { // grdSub.Rows[i].Cells[SecHTechParamIDCol].Value = oSub.HTechParamID.ToString(); // if (oTech.GetInfoByID(oSub.HTechParamID)) // { // grdSub.Rows[i].Cells[SecHTechParamNumberCol].Value = oTech.omodel.HNumber; // grdSub.Rows[i].Cells[SecHTechParamNameCol].Value = oTech.omodel.HName; // } // else // { // grdSub.Rows[i].Cells[SecHTechParamNumberCol].Value = ""; // grdSub.Rows[i].Cells[SecHTechParamNameCol].Value = ""; // } // grdSub.Rows[i].Cells[SecHTechParamUnitIDCol].Value = oSub.HTechParamUnitID.ToString(); // if (oTechU.GetInfoByID(oSub.HTechParamUnitID)) // { // grdSub.Rows[i].Cells[SecHTechParamUnitNumberCol].Value = oTechU.omodel.HNumber; // grdSub.Rows[i].Cells[SecHTechParamUnitNameCol].Value = oTechU.omodel.HName; // } // else // { // grdSub.Rows[i].Cells[SecHTechParamUnitNumberCol].Value = ""; // grdSub.Rows[i].Cells[SecHTechParamUnitNameCol].Value = ""; // } // } // else if (oSub.HType == "首件") // { // grdSub.Rows[i].Cells[SecHTechParamIDCol].Value = oSub.HTechParamID.ToString(); // if (oFirst.GetInfoByID(oSub.HTechParamID)) // { // grdSub.Rows[i].Cells[SecHTechParamNumberCol].Value = oFirst.omodel.HNumber; // grdSub.Rows[i].Cells[SecHTechParamNameCol].Value = oFirst.omodel.HName; // } // else // { // grdSub.Rows[i].Cells[SecHTechParamNumberCol].Value = ""; // grdSub.Rows[i].Cells[SecHTechParamNameCol].Value = ""; // } // grdSub.Rows[i].Cells[SecHTechParamUnitIDCol].Value = oSub.HTechParamUnitID.ToString(); // if (oFirstU.GetInfoByID(oSub.HTechParamUnitID)) // { // grdSub.Rows[i].Cells[SecHTechParamUnitNumberCol].Value = oFirstU.omodel.HNumber; // grdSub.Rows[i].Cells[SecHTechParamUnitNameCol].Value = oFirstU.omodel.HName; // } // else // { // grdSub.Rows[i].Cells[SecHTechParamUnitNumberCol].Value = ""; // grdSub.Rows[i].Cells[SecHTechParamUnitNameCol].Value = ""; // } // } // else // { // grdSub.Rows[i].Cells[SecHTechParamIDCol].Value = oSub.HTechParamID.ToString(); // if (oAuxiliary.GetInfoByID(oSub.HTechParamID)) // { // grdSub.Rows[i].Cells[SecHTechParamNumberCol].Value = oAuxiliary.omodel.HNumber; // grdSub.Rows[i].Cells[SecHTechParamNameCol].Value = oAuxiliary.omodel.HName; // } // else // { // grdSub.Rows[i].Cells[SecHTechParamNumberCol].Value = ""; // grdSub.Rows[i].Cells[SecHTechParamNameCol].Value = ""; // } // grdSub.Rows[i].Cells[SecHTechParamUnitNumberCol].Value = ""; // grdSub.Rows[i].Cells[SecHTechParamUnitNameCol].Value = ""; // } // grdSub.Rows[i].Cells[SecHProcNoCol].Value = oSub.HProcNo.ToString(); // grdSub.Rows[i].Cells[SecHValueCol].Value = oSub.HValue; // grdSub.Rows[i].Cells[SecHStdCol].Value = oSub.HStd; // grdSub.Rows[i].Cells[SecHTypeCol].Value = oSub.HType; // grdSub.Rows[i].Cells[SecHEntryIDCol].Value = oSub.HEntryID.ToString(); // i = i + 1; // } //} } #region 基本不变 //网格编辑前判断 private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { //int i = grdMain.CurrentCell.ColumnIndex; //if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid, i)) //{ // e.Cancel = true; //} } private void grdMain_Scroll(object sender, ScrollEventArgs e) { //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); oSumGrid.DisplayCurRow(); } //网格编辑后处理 private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e) { //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // if (this.EditingControl != null) //释放事件 { EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown); this.EditingControl = null; } } DataGridViewTextBoxEditingControl EditingControl; private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { //if (grdMain.CurrentCell != null) //{ // if (e.Control is DataGridViewTextBoxEditingControl) // { // this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control; // //增加委托处理 // this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown); // } //} } private void EditingControl_KeyDown(object sender, KeyEventArgs e) { //业务处理 //Sub_GridKey(e.KeyValue, grdMain.CurrentRow.Index, grdMain.CurrentCell.ColumnIndex, EditingControl); } private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e) { //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } //网格编辑前判断 private void grdSub_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { //int i = grdSub.CurrentCell.ColumnIndex; //if (DBUtility.ClsPub.isStrNull(grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[SecHTypeCol].Value) != "首件" && i == SecHStdCol) //{ // e.Cancel = true; //} //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 grdMain_CellClick(object sender, DataGridViewCellEventArgs e) { //long sEntryID = ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HEntryIDCol].Value); //if (sEntryID != 0) //{ // SaveSub(); // GetgrdSub(sEntryID); //} } private void SaveSub() { //if (BillStatus != DBUtility.ClsPub.Enum_BillStatus.BillStatus_View) //{ // long sEntryID = 0; // for (int i = 0; i <= grdSub.RowCount - 1; i++) // { // if (DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[SecHEntryIDCol].Value) != 0) // { // sEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[SecHEntryIDCol].Value); // break; // } // } // if (sEntryID == 0) // { // return; // } // for (int i = BillOld.DetailColl1.Count - 1; i >= 0; i--) // { // Model.ClsSc_StationEntrustOutBillSub_Item oSub = new Model.ClsSc_StationEntrustOutBillSub_Item(); // oSub = BillOld.DetailColl1[i]; // if (oSub.HEntryID == sEntryID) // { // BillOld.DetailColl1.Remove(BillOld.DetailColl1[i]); // } // } // //明细类赋值 // for (int i = 0; i <= grdSub.RowCount - 1; i++) // { // if (DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[SecHEntryIDCol].Value) != 0) // { // Model.ClsSc_StationEntrustOutBillSub_Item oSub = new Model.ClsSc_StationEntrustOutBillSub_Item(); // oSub.HEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[SecHEntryIDCol].Value); // oSub.HProcNo = ClsPub.isLong(grdSub.Rows[i].Cells[SecHProcNoCol].Value); // oSub.HTechParamID = ClsPub.isLong(grdSub.Rows[i].Cells[SecHTechParamIDCol].Value); // oSub.HTechParamUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[SecHTechParamUnitIDCol].Value); // oSub.HValue = ClsPub.isStrNull(grdSub.Rows[i].Cells[SecHValueCol].Value); // oSub.HStd = ClsPub.isStrNull(grdSub.Rows[i].Cells[SecHStdCol].Value); // oSub.HType = ClsPub.isStrNull(grdSub.Rows[i].Cells[SecHTypeCol].Value); // BillOld.DetailColl1.Add(oSub); // } // } //} } //单元格被单击,判断是否是放下拉框控件的那一列 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(grdMain, this.Name); //DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "1"); } private void cmbHSupID_Click(object sender, EventArgs e) { BLL.ClsBaseSelect.SetTextBySupplier(txtHSupID); //GetPrice(); } private void txtHSupID_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //获取控件位置 int x = 0; int y = 0; BLL.ClsPub_BLL.SetXY(this, panel2, gbUp, txtHSupID, ref x, ref y); //选择基础 DAL.ClsIF_Supplier_View oSup = new DAL.ClsIF_Supplier_View(); if (oSup.RefreshViewDownMenu(" and (HNumber like '%" + txtHSupID.Text + "%' or HName like '%" + txtHSupID.Text + "%') ", x, y)) { txtHSupID.Text = oSup.oModel.HName; txtHSupID.Tag = oSup.oModel.HItemID.ToString(); //txtHSupID.ForeColor = System.Drawing.Color.Blue; txtHBadPNL.Select(); } else { txtHSupID.Text = ""; //txtHSupID.ForeColor = System.Drawing.Color.Black; } //GetPrice(); txtHPrice.Select(); } } private void GetPrice() { //DataSet DsJG; //DataSet DsTaxRate; //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3(); //long HSupID = ClsPub.isLong(txtHSupID.Tag); //long HMaterID = ClsPub.isLong(txtHMaterID.Tag); //long HProcID = ClsPub.isLong(txtHProcID.Tag); //// //DsTaxRate = oCnK3.RunProcReturn("select FValueAddRate from t_Supplier where FItemID=" + HSupID, "h_p_MES_GetSupPrice"); //if (DsTaxRate == null || DsTaxRate.Tables[0].Rows.Count == 0) //{ // txtHTaxRate.Text = "0"; //} //else //{ // txtHTaxRate.Text = DsTaxRate.Tables[0].Rows[0]["FValueAddRate"].ToString(); //} //// //DsJG = oCn.RunProcReturn("exec h_p_MES_GetSupPrice " + HSupID + " ," + HMaterID + " ," + HProcID, "h_p_MES_GetSupPrice"); //if (DsJG == null) //{ // MessageBox.Show("获取单价失败!", "提示"); // return; //} //if (DsJG.Tables[0].Rows.Count == 0) //{ // txtHPrice.Text = "0"; // txtHMoney.Text = "0"; // txtHPrice_BHS.Text = "0"; // txtHMoney_BHS.Text = "0"; // txtHRemark.Text = ""; //} //else //{ // txtHPrice.Text = ClsPub.isStrNull(DBUtility.ClsPub.isDoule(DsJG.Tables[0].Rows[0]["HPrice"], 6)); // txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule((ClsPub.isDoule(txtHPieceQty.Text) + ClsPub.isDoule(txtHBadPNL.Text)) * ClsPub.isDoule(DBUtility.ClsPub.isDoule(DsJG.Tables[0].Rows[0]["HPrice"], 6)), 4)); // txtHPrice_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHPrice.Text) / (ClsPub.isDoule(txtHTaxRate.Text) / 100 + 1), 6)); // txtHMoney_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHMoney.Text) / (ClsPub.isDoule(txtHTaxRate.Text)/100+1), 4)); // txtHRemark.Text = DsJG.Tables[0].Rows[0]["HRemark"].ToString(); //} } private void txtHSupID_TextChanged(object sender, EventArgs e) { BLL.ClsPub_BLL.Sub_ClearText(txtHSupID); } private void cmdBF_Click(object sender, EventArgs e) { //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //DataSet Ds; //Ds = oCn.RunProcReturn("select HInterID from QC_NoPassProdCheckBillMain where HMainSourceInterID=" + BillOld.omodel.HInterID, "QC_NoPassProdCheckBillMain", ref ClsPub.sErrInfo); //if (Ds == null) //{ // MessageBox.Show("获取报废单失败:" + ClsPub.sErrInfo); // return; //} //if (Ds.Tables[0].Rows.Count == 0) //{ // DataSet DsCheck; // DsCheck = oCn.RunProcReturn("exec h_p_MES_StationOutBill_BFAdd " + BillOld.omodel.HInterID, "h_p_MES_StationOutBill_BFAdd"); // if (DsCheck == null) // { // MessageBox.Show("判断下道工序是否已经进站时出错!"); // return; // } // if (DsCheck.Tables[0].Rows.Count > 0) // { // MessageBox.Show("下道工序已经进站扫描,不允许生成MRB评审单!"); // return; // } // //if (ClsPub.isDoule(txtHWasterQty.Text) == 0 && ClsPub.isDoule(txtHBadPNL.Text) == 0) // //{ // // return; // //} // 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.txtHLotNo.Text = txtHProcExchBillNo.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.txtHPlanQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHWasterQty.Text) ); // oBF.txtHPlanPNL.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadPNL.Text)); // //oBF.txtHBadPNL.Text = "0"; // oBF.txtHBadPNL.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHBadPNL.Text)); // //oBF.txtHBadQty.Text = "0"; // oBF.txtHBadQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHWasterQty.Text)); // oBF.ShowDialog(); // if (oBF.BillChange) // { // this.Sub_ShowBill(); // } //} //else //{ // DAL.ClsQC_NoPassProdCheckBill oBill = new DAL.ClsQC_NoPassProdCheckBill(); // if (oBill.ShowBill(ClsPub.isLong(Ds.Tables[0].Rows[0][0]), ref DBUtility.ClsPub.sExeReturnInfo)) // { // QC_NoPassProdCheckBill oFrm = new QC_NoPassProdCheckBill(); // oFrm.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; // oFrm.BillOld = oBill; // oFrm.ShowDialog(); // if (oFrm.BillChange) // { // this.Sub_ShowBill(); // } // } // else // { // MessageBox.Show("单据未找到", "提示"); // } // oBill = null; //} } private void txtHPieceQty_TextChanged(object sender, EventArgs e) { if (sTextChanged == true) { sTextChanged = false; double HPlanPieceQty = ClsPub.isDoule(txtHPlanPieceQty.Text); //发出PNL数 double HPieceQty = ClsPub.isDoule(txtHPieceQty.Text); //接收PNL数 double HPrice = ClsPub.isDoule(ClsPub.isDoule(txtHPrice.Text, 6)); //单价 double HTaxRate = ClsPub.isDoule(txtHTaxRate.Text); //税率 double HBadPNL = ClsPub.isDoule(txtHBadPNL.Text); //报废PNL数 txtHBadPNL.Text = ClsPub.isStrNull(HPlanPieceQty - HPieceQty); txtHPrice_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HPrice / (HTaxRate / 100 + 1), 6)); txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule((HPlanPieceQty) * HPrice, 4)); double HMoney = ClsPub.isDoule(txtHMoney.Text); //金额 txtHMoney_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HMoney / (HTaxRate / 100 + 1), 4)); sTextChanged = true; } } private void txtHQty_TextChanged(object sender, EventArgs e) { //if (sTextChanged == true) //{ // sTextChanged = false; // txtHWasterQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanQty.Text) - ClsPub.isDoule(txtHQty.Text)); // sTextChanged = true; //} Proce_WhorkOut(); } private void txtHBadPNL_TextChanged(object sender, EventArgs e) { //if (sTextChanged == true) //{ // sTextChanged = false; // double HPlanPieceQty = ClsPub.isDoule(txtHPlanPieceQty.Text); //发出PNL数 // double HPrice = ClsPub.isDoule(ClsPub.isDoule(txtHPrice.Text, 6)); //单价 // double HTaxRate = ClsPub.isDoule(txtHTaxRate.Text); //税率 // double HBadPNL = ClsPub.isDoule(txtHBadPNL.Text); //报废PNL数 // txtHPieceQty.Text = ClsPub.isStrNull(HPlanPieceQty - HBadPNL); // double HPieceQty = ClsPub.isDoule(txtHPieceQty.Text); //接收PNL数 // txtHPrice_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HPrice / (HTaxRate / 100 + 1), 6)); // txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule((HPlanPieceQty) * HPrice, 4)); // double HMoney = ClsPub.isDoule(txtHMoney.Text); //金额 // txtHMoney_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HMoney / (HTaxRate / 100 + 1), 4)); // sTextChanged = true; //} } private void txtHBadPNL_Leave(object sender, EventArgs e) { } private void txtHWasterQty_TextChanged(object sender, EventArgs e) { //if (sTextChanged == true) //{ // sTextChanged = false; // txtHQty.Text = ClsPub.isStrNull(ClsPub.isDoule(txtHPlanQty.Text) - ClsPub.isDoule(txtHWasterQty.Text)); // sTextChanged = true; //} } private void txtHPieceQty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHQty.Select(); } } private void txtHQty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHPrice.Select(); } } private void txtHBadPNL_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHWasterQty.Select(); } } private void txtHWasterQty_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHPieceQty.Select(); } } private void txtHPieceQty_Leave(object sender, EventArgs e) { } 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 Sub_EditBill() { //判断权限 if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName)) { return; } //判断该用户名是否有该工站权限 //if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(66865)) == false) //{ // MessageBox.Show("没有该工站权限!", "提示"); // return; //} //检查是否开票 //string d = ""; //if (BillOld.CheckIsKP(BillOld.omodel.HInterID, ref d) == false) //{ // MessageBox.Show(d, "提示"); // return; //} // string s = ""; if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false) { MessageBox.Show("此单据有错误!", "提示"); return; } //判断是否可编辑 if (BillOld.omodel.HChecker != "") { MessageBox.Show("此单据已经被审核,不允许修改", "提示"); return; } //判断是否可编辑 txtHPieceQty.Enabled = false; txtHQty.Enabled = true; txtHBadPNL.Enabled = false; txtHWasterQty.Enabled = true; txtHTaxRate.Enabled = true; // 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 txtHPrice_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { cmdOK.Select(); } } private void txtHMoney_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { txtHRemark.Select(); } } private void txtHPrice_Leave(object sender, EventArgs e) { Proce_WhorkOut(); } private void txtHMoney_Leave(object sender, EventArgs e) { Proce_WhorkOut(); } private void txtHPrice_TextChanged(object sender, EventArgs e) { Proce_WhorkOut(); //if (sTextChanged == true) //{ // sTextChanged = false; // double HPrice = ClsPub.isDoule(ClsPub.isDoule(txtHPrice.Text, 6)); //单价 // double HTaxRate = ClsPub.isDoule(txtHTaxRate.Text); //税率 // double HBadPNL = ClsPub.isDoule(txtHBadPNL.Text); //报废PNL数 // double HPieceQty = ClsPub.isDoule(txtHPieceQty.Text); //接收PNL数 // txtHMoney.Text = ClsPub.isStrNull(ClsPub.isDoule((HPieceQty + HBadPNL) * HPrice, 4)); // double HMoney = ClsPub.isDoule(txtHMoney.Text); //金额 // txtHPrice_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HPrice / (HTaxRate / 100 + 1), 6)); // txtHMoney_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HMoney / (HTaxRate / 100 + 1), 4)); // sTextChanged = true; //} } private void txtHMoney_TextChanged(object sender, EventArgs e) { //if (sTextChanged == true) //{ // sTextChanged = false; // double HMoney = ClsPub.isDoule(txtHMoney.Text); //金额 // double HBadPNL = ClsPub.isDoule(txtHBadPNL.Text); //报废PNL数 // double HPieceQty = ClsPub.isDoule(txtHPieceQty.Text); //接收PNL数 // double HTaxRate = ClsPub.isDoule(txtHTaxRate.Text); //税率 // if ((HPieceQty + HBadPNL) == 0) // { // txtHPrice.Text = "0"; // } // else // { // txtHPrice.Text = ClsPub.isStrNull(ClsPub.isDoule(HMoney / (HPieceQty + HBadPNL), 6)); // } // double HPrice = ClsPub.isDoule(ClsPub.isDoule(txtHPrice.Text, 6)); //单价 // txtHPrice_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HPrice / (HTaxRate / 100 + 1), 6)); // txtHMoney_BHS.Text = ClsPub.isStrNull(ClsPub.isDoule(HMoney / (HTaxRate / 100 + 1), 4)); // sTextChanged = true; //} } public double sMath(double a,int b) { a = Math.Round((double)(a), b, MidpointRounding.AwayFromZero); return a; } private void txtHProcNO_KeyDown(object sender, KeyEventArgs e) { 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; } //得到信息 Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 单据号= '" + sBillNo + "' and 下道流转工序<>'转' and 委外标记=1 and 流转标记=1 and 工序号='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList"); //写入信息 if (Ds == null || Ds.Tables[0].Rows.Count == 0) { txtHProcNO.Text = ""; MessageBox.Show("流水号错误,请重新输入!"); return; } if (DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["委外标记"].ToString()) != true) { txtHProcNO.Text = ""; MessageBox.Show("该工序不是委外工序,请重新输入!"); return; } for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { Sub_WriteInForm_SM2(Ds.Tables[0], i); } int sHSupID = ClsPub.isInt(txtHSupID.Tag.ToString()); int sHMaterID = ClsPub.isInt(txtHMaterID.Tag.ToString()); Ds = oCn.RunProcReturn("select top 1 * from WW_EntrustWorkOrderBillSub where HSourceInterID= '" + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainID"]) + "' and HSourceEntryID='" + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSubID"]) + "'", "Gy_ProcCommPrice"); if (Ds == null || Ds.Tables[0].Rows.Count == 0) { this.txtHPrice_BHS.Text = ""; this.txtHPrice.Text = ""; this.txtHTaxRate.Text = ""; } else { //this.txtHPrice_BHS.Text = Ds.Tables[0].Rows[0]["HPrice"].ToString(); //this.txtHPrice.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPrice"]) * (1.00 + (Pub_Class.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HTaxRate"]) / 100.00))); this.txtHPrice.Text = Ds.Tables[0].Rows[0]["HPrice"].ToString(); this.txtHPrice_BHS.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPrice"]) / ((1.00 + ( 16.0000 / 100.0000)))); this.txtHTaxRate.Text ="16"; } txtHQty.Focus(); } } //根据TABLE写入界面 private void Sub_WriteInForm_SM2(DataTable oTable, int i) { DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View(); SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; lngBillSubKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HSubID"]); lngBillKey = DBUtility.ClsPub.isLong(oTable.Rows[0]["HMainID"]); //控制委外发出单 必须有 委外工单(目前存储过程里是 跳过的) ds = oCn.RunProcReturn("exec h_p_MES_StationEntrustOutBill_Ctrl " + lngBillKey.ToString() + "," + lngBillSubKey.ToString() + "", "h_p_MES_StationEntrustOutBill_Ctrl"); if(ds==null || ds.Tables[0].Rows.Count==0) { MessageBox.Show("判断委外工单失败!"); txtHProcNO.Text=""; txtHProcNO.Focus(); return ; } else { if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][0]) == "2") { MessageBox.Show(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][1])); txtHProcNO.Text = ""; txtHProcNO.Focus(); return; } } //this.txtHProcExchInterID.Text = oTable.Rows[0]["hmainid"].ToString(); //this.txtHProcExchEntryID.Text = oTable.Rows[0]["hsubid"].ToString(); // this.txtHProcID.Tag = oTable.Rows[0]["HProcID"].ToString(); this.txtHProcID.Text = oTable.Rows[0]["工序"].ToString(); //this.txtHDeptID.Tag = oTable.Rows[0]["HDeptID"].ToString(); //this.txtHDeptID.Text = oTable.Rows[0]["加工车间"].ToString(); //this.txtHGroupID.Tag = oTable.Rows[0]["HGroupID"].ToString(); //this.txtHGroupID.Text = oTable.Rows[0]["班组"].ToString(); //this.txtHWorkEmpID.Tag = oTable.Rows[0]["HWorkerID"].ToString(); //this.txtHWorkEmpID.Text = oTable.Rows[0]["操作工"].ToString(); //this.txtHSourceID.Tag = oTable.Rows[0]["HSourceID"].ToString(); //this.txtHSourceID.Text = oTable.Rows[0]["生产资源"].ToString(); this.txtHSupID.Tag = oTable.Rows[0]["HSupID"].ToString(); this.txtHSupID.Text = oTable.Rows[0]["供应商"].ToString(); //txtHProcExchInterID.Text = oTable.Rows[0]["hmainid"].ToString(); //txtHProcExchEntryID.Text = oTable.Rows[0]["hsubID"].ToString(); //根据流转卡内码 获取工单内码(唯一工单或者唯一未接受完毕工单) //如果 没有扫描 及 流水号 则 报错 if (lngBillKey == 0 || lngBillSubKey == 0) { return; } //根据工号获取委外工单 及内码,子内码 --根据流转卡主内码子内码 获取 委外工单信息 //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); ds = oCn.RunProcReturn("exec h_p_WW_GetWWWorkBillInfoByHProcExch " + lngBillKey.ToString() + "," + lngBillSubKey.ToString(), "h_p_WW_GetWWWorkBillInfoByHProcExch"); if (ds == null) { //MessageBox.Show("没有找到对应的委外工单!"); return; } if (ds.Tables[0].Rows.Count > 0 && DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 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 Proce_WhorkOut() { txtHMoney.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(txtHQty.Text) * Pub_Class.ClsPub.isDoule(txtHPrice.Text)); txtHMoney_BHS.Text = Pub_Class.ClsPub.isStrNull(Pub_Class.ClsPub.isDoule(txtHQty.Text) * Pub_Class.ClsPub.isDoule(txtHPrice_BHS.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_StationEntrustOutBill_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_StationEntrustOutBill oBill = new DAL.ClsSc_StationEntrustOutBill(); //查看是否已审核,关闭,作废 if (oBill.ShowBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HChecker.Trim() != "") { MessageBox.Show("单据已审核!不能再次审核", "提示"); return; } } else { MessageBox.Show("单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); return; } //判断是否已经存在 ruku单 //审核 if (oBill.CheckBill(lInterID, ref DBUtility.ClsPub.sExeReturnInfo) == true) { MessageBox.Show("审核成功!", "提示"); return; } else { //删除同名ruku 单 // 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_StationEntrustOutBill oBill = new DAL.ClsSc_StationEntrustOutBill(); //查看是否已审核,关闭,作废 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; } } } GridppReport Report; private void button3_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(true); } } //找到对应打印模块 private void Sub_SetReport(string sOpenTmp) { // Report = new GridppReport(); Report.LoadFromFile(ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord); Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); } //赋值表头 private void ReportBeforePostRecord()// { try { Report.FieldByName("编号").AsString = txtHInnerBillNo.Text; Report.FieldByName("日期").AsString = txtHStationOutTime.Text; Report.FieldByName("供应商").AsString = txtHSupID.Text; Report.FieldByName("制单").AsString = DBUtility.ClsPub.CurUserName; //Report.FieldByName("表头备注").AsString = txtHRemark.Text; //Report.FieldByName("物料代码").AsString = txtHMaterID.Text; //Report.FieldByName("物料名称").AsString = txtHMaterName.Text; //Report.FieldByName("规格型号").AsString = txtHMaterModel.Text; //Report.FieldByName("计量单位名称").AsString = "件"; //Report.FieldByName("仓库名称").AsString = txtHProcID.Text; //Report.FieldByName("数量").AsString = txtHQty.Text; //Report.FieldByName("表体备注").AsString = txtHRemark.Text; //Report.FieldByName("订单跟踪号").AsString = txtHOrderProcNO.Text; //grdMain.Columns[HRemarkCol].HeaderText = "备注"; //grdMain.Columns[HMaterNumberCol].HeaderText = "物料代码"; //grdMain.Columns[HMaterNameCol].HeaderText = "物料名称"; //grdMain.Columns[HMaterModelCol].HeaderText = "规格型号"; //grdMain.Columns[HUnitNameCol].HeaderText = "计量单位名称"; //grdMain.Columns[HQtyCol].HeaderText = "数量"; //grdMain.Columns[HWhNameCol].HeaderText = "仓库名称"; //grdMain.Columns[HOrderProcNoCol].HeaderText = "订单跟踪号"; } catch (Exception e) { MessageBox.Show("打印失败"+ e.Message); } } //赋值表体 private void ReportFetchRecordByDataTable() { try { DataTable dt = new DataTable(); BLL.Utility.FillRecordToReport(Report, grdMain, dt, HMaterNumberCol); } catch (Exception e) { MessageBox.Show("打印失败2,"+ e.Message); } } private void gbUp_Enter(object sender, EventArgs e) { } 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; } //if (e.KeyCode == Keys.Enter) //{ // DAL.ClsSc_ProcessExchangeBill oPeb = new DAL.ClsSc_ProcessExchangeBill(); // if (oPeb.GetIDByNo(DBUtility.ClsPub.isStrNull(txtHProcExchBillNo.Text), ref ClsPub.sExeReturnInfo) == false) // { // MessageBox.Show(ClsPub.sExeReturnInfo, "提示"); // lngBillKey = 0; // lngBillSubKey = 0; // txtHProcID.Tag = 0; // txtHProcID.Text = ""; // txtHProcExchBillNo.Text = ""; // return; // } // lngBillKey = oPeb.omodel.HInterID; // lngBillSubKey = 0; // txtHProcID.Tag = 0; // txtHProcID.Text = ""; // LotShow(); //} } } }