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 Sc_ProcessPlanChangeSec : Form { public Sc_ProcessPlanChangeSec() { InitializeComponent(); } //定义网格列 public const Int16 HTagCol = 0; //标识列 public const Int16 HSnoCol = 1; //序号列 public const Int16 HBillNoCol = 2; public const Int16 HProcNoCol = 3; public const Int16 HProcIDCol = 4; //工序ID public const Int16 HProcNumberCol = 5; //工序代码 F7 public const Int16 HProcNameCol = 6; //工序名称 public const Int16 HWorkRemarkCol = 7; public const Int16 HCenterIDCol = 8; public const Int16 HCenterNumberCol = 9; public const Int16 HCenterNameCol = 10; public const Int16 HDeptIDCol = 11; public const Int16 HDeptNumberCol = 12; public const Int16 HDeptNameCol = 13; public const Int16 HGroupIDCol = 14; public const Int16 HGroupNumberCol = 15; public const Int16 HGroupNameCol = 16; public const Int16 HWorkerIDCol = 17; public const Int16 HWorkerNumberCol = 18; public const Int16 HWorkerNameCol = 19; public const Int16 HSourceIDCol = 20; public const Int16 HSourceNumberCol = 21; public const Int16 HSourceNameCol = 22; public const Int16 HQtyCol = 23; public const Int16 HWorkingQtyCol = 24; public const Int16 HTimeUnitCol = 25; public const Int16 HPlanWorkTimesCol = 26; public const Int16 HPlanBeginDateCol = 27; public const Int16 HPlanEndDateCol = 28; public const Int16 HICMOInterIDCol = 29; public const Int16 HICMOBillNoCol = 30; public const Int16 HSeOrderInterIDCol = 31; public const Int16 HSeOrderEntryIDCol = 32; public const Int16 HSeOrderBillNoCol = 33; public const Int16 HCloseManCol = 34; public const Int16 HCloseTypeCol = 35; public const Int16 HRelationQtyCol =36; public const Int16 HRelationMoneyCol =37; public const Int16 HSourceInterIDCol = 38; public const Int16 HSourceEntryIDCol = 39; public const Int16 HSourceBillNoCol = 40; public const Int16 HSourceBillTypeCol = 41; public const Int16 HRemarkCol = 42; // public string ModName = "3715"; public string ModCaption = "工序计划变更单"; public bool BillChange; // public string HInnerBillNo = ""; public Int64 PlanNoCount = 1;//工序号计数 public DBUtility.ClsPub.Enum_BillStatus BillStatus; //单据状态(新增,修改,视图) public Int64 KeyID; //作废 public bool grdStatus; //网格状态(编辑,视图) public DAL.ClsSc_ProcessPlanChangeSec BillNew = new DAL.ClsSc_ProcessPlanChangeSec(); //单据类 public DAL.ClsSc_ProcessPlanChangeSec BillOld = new DAL.ClsSc_ProcessPlanChangeSec(); //单据类 ClsGridViewSum oSumGrid = new ClsGridViewSum(); //------------------------------------------------------------------------- #region 固定代码 //清空界面 public void Sub_ClearBill() { DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp); // txtHMaker.Text = ClsPub.CurUserName; txtHMakeDate.Text = ""; txtHChecker.Text = ""; txtHCheckDate.Text = ""; txtHCloseMan.Text = ""; txtHCloseDate.Text = ""; txtHDeleteMan.Text = ""; txtHDeleteDate.Text = ""; txtHUpDater.Text = ""; txtHUpDateDate.Text = ""; txtHBacker.Text = ""; txtHBackDate.Text = ""; initGrid(); } //编辑单据 private void Sub_EditBill() { string s = ""; if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false) { MessageBox.Show("此单据有错误!", "提示"); return; } if (BillOld.omodel.HChecker != "") { MessageBox.Show("此单据已经被审核,不允许修改", "提示"); return; } this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; this.Sub_OperStatus(); txtHUpDater.Text = ClsPub.CurUserName; txtHBillNo.Enabled = false; } //删除单据 private void Sub_DeleteBill() { string s = ""; if (BillOld.ShowBill(BillOld.omodel.HInterID, ref s) == false) { MessageBox.Show("此单据有错误!", "提示"); return; } if (BillOld.omodel.HChecker != "") { MessageBox.Show("此单据已经被审核,不允许审核", "提示"); return; } if (MessageBox.Show("确定要删除当前单据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); Ds = oCn.RunProcReturn("select isnull(HWorkingQty,0) from Sc_ProcessPlanChangeSecSub where HWorkingQty<>0 and hinterid=" + BillOld.omodel.HInterID, "Sc_ProcessPlanChangeSecSub"); if (Ds.Tables[0].Rows.Count > 0) { MessageBox.Show("删除失败,原因:已有关联数量" + ClsPub.sExeReturnInfo, "提示"); return; } else if (BillOld.DeleteBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) { if (BillOld.DeleteBill2(BillOld.omodel.HICMOInterID, ref ClsPub.sExeReturnInfo) != true) { BillChange = true; MessageBox.Show("删除失败,原因:" + ClsPub.sExeReturnInfo, "提示"); return; } BillChange = true; MessageBox.Show("删除成功", "提示"); return; } else { BillChange = true; MessageBox.Show("删除失败,原因:" + ClsPub.sExeReturnInfo, "提示"); return; } MessageBox.Show("删除成功", "提示"); BillOld = new DAL.ClsSc_ProcessPlanChangeSec(); this.Sub_Next(); //显示下一张单据 if (BillOld.omodel.HInterID == 0)//若找不到下一张,则显示上一张 { this.Sub_Prev(); } if (BillOld.omodel.HInterID == 0)//若找不到上一张,清空 { this.Sub_ClearBill(); } BillStatus =DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; this.Sub_OperStatus(); } } private void bclk_Click(object sender, EventArgs e) { //保存列宽 DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } //增行按钮 private void AddRow_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.AddRow(oSumGrid); } //删行按纽 private void DelRow_Click(object sender, EventArgs e) { for (int i=0;i= grdMain.RowCount - 1) grdMain.Rows.Add(); grdMain.Rows[i].Cells[HTagCol].Value = "*"; grdMain.Rows[i].Cells[HProcIDCol].Value = oSub.HProcID.ToString(); if (oProc.GetInfoByID(oSub.HProcID)) { grdMain.Rows[i].Cells[HProcNumberCol].Value = oProc.omodel.HNumber; grdMain.Rows[i].Cells[HProcNameCol].Value = oProc.omodel.HName; } else { grdMain.Rows[i].Cells[HProcNumberCol].Value = ""; grdMain.Rows[i].Cells[HProcNameCol].Value = ""; } // grdMain.Rows[i].Cells[HCenterIDCol].Value = oSub.HCenterID.ToString(); if (oWork.GetInfoByID(oSub.HCenterID)) { grdMain.Rows[i].Cells[HCenterNumberCol].Value = oWork.omodel.HNumber; grdMain.Rows[i].Cells[HCenterNameCol].Value = oWork.omodel.HName; } else { grdMain.Rows[i].Cells[HCenterNameCol].Value = ""; grdMain.Rows[i].Cells[HCenterNumberCol].Value = ""; } // grdMain.Rows[i].Cells[HDeptIDCol].Value = oSub.HDeptID.ToString(); if (oDept.GetInfoByID(oSub.HDeptID)) { grdMain.Rows[i].Cells[HDeptNumberCol].Value = oDept.omodel.HNumber; grdMain.Rows[i].Cells[HDeptNameCol].Value = oDept.omodel.HName; } else { grdMain.Rows[i].Cells[HDeptNameCol].Value = ""; grdMain.Rows[i].Cells[HDeptNumberCol].Value = ""; } // grdMain.Rows[i].Cells[HGroupIDCol].Value = oSub.HGroupID.ToString(); if (oGroup.GetInfoByID(oSub.HGroupID)) { grdMain.Rows[i].Cells[HGroupNumberCol].Value = oGroup.omodel.HNumber; grdMain.Rows[i].Cells[HGroupNameCol].Value = oGroup.omodel.HName; } else { grdMain.Rows[i].Cells[HGroupNameCol].Value = ""; grdMain.Rows[i].Cells[HGroupNumberCol].Value = ""; } // grdMain.Rows[i].Cells[HWorkerIDCol].Value = oSub.HWorkerID.ToString(); if (oEmp.GetInfoByID(oSub.HWorkerID)) { grdMain.Rows[i].Cells[HWorkerNumberCol].Value = oEmp.omodel.HNumber; grdMain.Rows[i].Cells[HWorkerNameCol].Value = oEmp.omodel.HName; } else { grdMain.Rows[i].Cells[HWorkerNameCol].Value = ""; grdMain.Rows[i].Cells[HWorkerNumberCol].Value = ""; } // grdMain.Rows[i].Cells[HSourceIDCol].Value = oSub.HSourceID.ToString(); if (oSour.GetInfoByID(oSub.HSourceID)) { grdMain.Rows[i].Cells[HSourceNumberCol].Value = oSour.omodel.HNumber; grdMain.Rows[i].Cells[HSourceNameCol].Value = oSour.omodel.HName; } else { grdMain.Rows[i].Cells[HSourceNameCol].Value = ""; grdMain.Rows[i].Cells[HSourceNumberCol].Value = ""; } // grdMain.Rows[i].Cells[HBillNoCol].Value = oSub.HBillNo; grdMain.Rows[i].Cells[HProcNoCol].Value = oSub.HProcNo.ToString(); grdMain.Rows[i].Cells[HWorkRemarkCol].Value = oSub.HWorkRemark; grdMain.Rows[i].Cells[HQtyCol].Value = oSub.HQty.ToString(); grdMain.Rows[i].Cells[HTimeUnitCol].Value = oSub.HTimeUnit; grdMain.Rows[i].Cells[HPlanWorkTimesCol].Value = oSub.HPlanWorkTimes.ToString(); grdMain.Rows[i].Cells[HPlanBeginDateCol].Value = oSub.HPlanBeginDate.ToShortDateString(); grdMain.Rows[i].Cells[HPlanEndDateCol].Value = oSub.HPlanEndDate.ToShortDateString(); grdMain.Rows[i].Cells[HICMOInterIDCol].Value = oSub.HICMOInterID.ToString(); grdMain.Rows[i].Cells[HICMOBillNoCol].Value = oSub.HICMOBillNo; grdMain.Rows[i].Cells[HSeOrderInterIDCol].Value = oSub.HSeOrderInterID.ToString(); grdMain.Rows[i].Cells[HSeOrderEntryIDCol].Value = oSub.HSeOrderEntryID.ToString(); grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value = oSub.HSeOrderBillNo; grdMain.Rows[i].Cells[HRemarkCol].Value = oSub.HRemark; grdMain.Rows[i].Cells[HWorkingQtyCol].Value = oSub.HWorkingQty.ToString(); // grdMain.Rows[i].Cells[HCloseManCol].Value = oSub.HCloseMan; //grdMain.Rows[i].Cells[HCloseTypeCol].Value = oSub.HCloseType ; grdMain.Rows[i].Cells[HSourceInterIDCol].Value = oSub.HSourceInterID.ToString(); grdMain.Rows[i].Cells[HSourceEntryIDCol].Value = oSub.HSourceEntryID.ToString(); grdMain.Rows[i].Cells[HSourceBillNoCol].Value = oSub.HSourceBillNo; grdMain.Rows[i].Cells[HSourceBillTypeCol].Value = oSub.HSourceBillType; grdMain.Rows[i].Cells[HRelationQtyCol].Value = oSub.HRelationQty.ToString(); grdMain.Rows[i].Cells[HRelationMoneyCol].Value = oSub.HRelationMoney.ToString(); i = i + 1; } //GRID允许刷新 DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // Sub_OperStatus(); } //单据完整性判断 未完成 private bool Sub_AllowSave() { //必输项目是否为空 if (ClsPub.isLong(txtHMaterID.Tag) == 0) { MessageBox.Show("产品不存在!", "提示"); return false; } if (ClsPub.isLong(txtHUnitID.Tag) == 0) { MessageBox.Show("单位不存在!", "提示"); return false; } if (ClsPub.isStrNull(txtHICMOBillNo.Text) == "") { MessageBox.Show("任务单不存在!", "提示"); return false; } //单据号是否重复 //if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, txtHBillNo.Text.Trim(), BillStatus, BillOld.omodel.HInterID)) //{ // MessageBox.Show("单据号重复!", "提示"); // return false; //} //明细表是否为零行 bool b = false; for (int i = 0; i < grdMain.RowCount; i++) { if (!IsNullRow(i)) { b = true; break; } } if (b == false) { MessageBox.Show("明细行不存在!", "提示"); return false; } return true; } //保存单据 private bool Sub_SaveBill() { Model.ClsSc_ProcessPlanSub oBillSub = new Model.ClsSc_ProcessPlanSub(); Int32 i; bool bResult; lblCaption.Focus(); BillNew = new DAL.ClsSc_ProcessPlanChangeSec(); 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.HDate = this.dtpHDate.Value; BillNew.omodel.HICMOBillNo = this.txtHICMOBillNo.Text.Trim(); BillNew.omodel.HMaterID = ClsPub.isLong(this.txtHMaterID.Tag); BillNew.omodel.HMaterNumber = this.txtHMaterNumber.Text.Trim(); BillNew.omodel.HUnitID = ClsPub.isLong(this.txtHUnitID.Tag); BillNew.omodel.HUnitNumber = this.txtHUnitNumber.Text.Trim(); BillNew.omodel.HPlanQty = ClsPub.isDoule(this.txtHPlanQty.Text); BillNew.omodel.HPlanBeginDate = this.dtpHPlanBeginDate.Value; BillNew.omodel.HPlanEndDate = this.dtpHPlanEndDate.Value; BillNew.omodel.HExplanation = this.txtHExplanation.Text.Trim(); BillNew.omodel.HInnerBillNo = this.txtHInnerBillNo.Text.Trim(); BillNew.omodel.HRemark = this.txtHRemark.Text.Trim(); BillNew.omodel.HInterID = ClsPub.isLong(this.txtHBillNo.Tag); //明细类赋值 BillNew.DetailColl=new List(); for (i = 0; i <= grdMain.RowCount - 1; i++) { if (ClsPub.isLong( grdMain.Rows[i].Cells[HProcIDCol].Value) != 0 ) { Model.ClsSc_ProcessPlanSub oSub = new Model.ClsSc_ProcessPlanSub(); oSub.HEntryID = i; // grdMain.Rows[i].Cells[HProcNoCol].Value = Convert.ToString(i+1); oSub.HProcNo = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HProcNoCol].Value); oSub.HProcID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HProcIDCol].Value); oSub.HProcNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNumberCol].Value); oSub.HWorkRemark = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HWorkRemarkCol].Value); oSub.HCenterID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HCenterIDCol].Value); oSub.HDeptID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HDeptIDCol].Value); oSub.HDeptNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HDeptNumberCol].Value); oSub.HGroupID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HGroupIDCol].Value); oSub.HGroupNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HGroupNumberCol].Value); oSub.HWorkerID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HWorkerIDCol].Value); oSub.HWorkerNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HWorkerNumberCol].Value); oSub.HSourceID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSourceIDCol].Value); oSub.HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HQtyCol].Value); oSub.HTimeUnit = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HTimeUnitCol].Value); oSub.HPlanWorkTimes = DBUtility.ClsPub.isSingle(grdMain.Rows[i].Cells[HPlanWorkTimesCol].Value); if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HPlanBeginDateCol].Value) == "") grdMain.Rows[i].Cells[HPlanBeginDateCol].Value = DateTime.Today.ToShortDateString(); oSub.HPlanBeginDate = DBUtility.ClsPub.isDate(grdMain.Rows[i].Cells[HPlanBeginDateCol].Value); if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HPlanEndDateCol].Value) == "") grdMain.Rows[i].Cells[HPlanEndDateCol].Value = DateTime.Today.ToShortDateString(); oSub.HPlanEndDate = DBUtility.ClsPub.isDate(grdMain.Rows[i].Cells[HPlanEndDateCol].Value); if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HICMOInterIDCol].Value) == 0 && i != 0) grdMain.Rows[i].Cells[HICMOInterIDCol].Value = grdMain.Rows[i - 1].Cells[HICMOInterIDCol].Value; oSub.HICMOInterID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HICMOInterIDCol].Value); if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HICMOBillNoCol].Value) == "" && i != 0) grdMain.Rows[i].Cells[HICMOBillNoCol].Value = grdMain.Rows[i - 1].Cells[HICMOBillNoCol].Value; oSub.HICMOBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HICMOBillNoCol].Value); if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSeOrderInterIDCol].Value) == 0 && i != 0) grdMain.Rows[i].Cells[HSeOrderInterIDCol].Value = grdMain.Rows[i - 1].Cells[HSeOrderInterIDCol].Value; oSub.HSeOrderInterID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSeOrderInterIDCol].Value); if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSeOrderEntryIDCol].Value) == 0 && i != 0) grdMain.Rows[i].Cells[HSeOrderEntryIDCol].Value = grdMain.Rows[i - 1].Cells[HSeOrderEntryIDCol].Value; oSub.HSeOrderEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSeOrderEntryIDCol].Value); if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value) == "" && i != 0) grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value = grdMain.Rows[i - 1].Cells[HSeOrderBillNoCol].Value; oSub.HSeOrderBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value); oSub.HWorkingQty = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HWorkingQtyCol].Value); // //oSub.HCloseMan = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HCloseManCol].Value); //oSub.HCloseType = DBUtility.ClsPub.isBool(grdMain.Rows[i].Cells[HCloseType].Value); oSub.HRemark = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HRemarkCol].Value); if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSourceInterIDCol].Value) == 0 && i != 0) grdMain.Rows[i].Cells[HSourceInterIDCol].Value = grdMain.Rows[i - 1].Cells[HSourceInterIDCol].Value; oSub.HSourceInterID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSourceInterIDCol].Value); if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSourceEntryIDCol].Value) == 0 && i != 0) grdMain.Rows[i].Cells[HSourceEntryIDCol].Value = grdMain.Rows[i - 1].Cells[HSourceEntryIDCol].Value; oSub.HSourceEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSourceEntryIDCol].Value); if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSourceBillTypeCol].Value) == "" && i != 0) grdMain.Rows[i].Cells[HSourceBillTypeCol].Value = grdMain.Rows[i - 1].Cells[HSourceBillTypeCol].Value; oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSourceBillTypeCol].Value); if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSourceBillNoCol].Value) == "" && i != 0) grdMain.Rows[i].Cells[HSourceBillNoCol].Value = grdMain.Rows[i - 1].Cells[HSourceBillNoCol].Value; oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HSourceBillNoCol].Value); oSub.HRelationQty = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HRelationQtyCol].Value); if (ClsPub.isDoule(grdMain.Rows[i].Cells[HQtyCol].Value) <=0 ) { int j = i + 1; MessageBox.Show("第" + j.ToString() + "行数量异常"); return false; } if (ClsPub.isDoule(grdMain.Rows[i].Cells[HQtyCol].Value) < ClsPub.isDoule(grdMain.Rows[i].Cells[HRelationQtyCol].Value) && grdMain.Rows[i].Cells[HBillNoCol].Value.ToString() != "") { int j = i + 1; MessageBox.Show("第" + j.ToString() + "行小于关联数量"); return false; } if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HBillNoCol].Value) == "") { grdMain.Rows[i].Cells[HBillNoCol].Value = "GXJH" + Convert.ToString(ClsPub.isLong(this.txtHBillNo.Tag) * 10000 + PlanNoCount); PlanNoCount++; } oSub.HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HBillNoCol].Value); oSub.HRelationMoney = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HRelationMoneyCol].Value); BillNew.DetailColl.Add(oSub); } } //保存完毕后处理 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 = 43; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name); //// grdMain.Columns[HSnoCol].HeaderText = "序号"; grdMain.Columns[HRemarkCol].HeaderText = "备注"; // grdMain.Columns[HBillNoCol].HeaderText = "工序计划单号"; grdMain.Columns[HProcNoCol].HeaderText = "工序号"; grdMain.Columns[HProcNameCol].HeaderText = "工序"; grdMain.Columns[HProcNumberCol].HeaderText = "工序代码"; grdMain.Columns[HWorkRemarkCol].HeaderText = "加工说明"; grdMain.Columns[HCenterNameCol].HeaderText = "工作中心"; grdMain.Columns[HDeptNameCol].HeaderText = "加工车间"; grdMain.Columns[HDeptNumberCol].HeaderText = "加工车间代码"; grdMain.Columns[HGroupNameCol].HeaderText = "班组"; grdMain.Columns[HGroupNumberCol].HeaderText = "班组代码"; grdMain.Columns[HWorkerNameCol].HeaderText = "操作工"; grdMain.Columns[HWorkerNumberCol].HeaderText = "操作工代码"; grdMain.Columns[HSourceNameCol].HeaderText = "生产资源"; grdMain.Columns[HQtyCol].HeaderText = "计划数量"; grdMain.Columns[HWorkingQtyCol].HeaderText = "在制品数量"; grdMain.Columns[HTimeUnitCol].HeaderText = "时间单位"; grdMain.Columns[HPlanWorkTimesCol].HeaderText = "计划加工时间"; grdMain.Columns[HPlanBeginDateCol].HeaderText = "计划开工日期"; grdMain.Columns[HPlanEndDateCol].HeaderText = "计划完工日期"; grdMain.Columns[HICMOInterIDCol].HeaderText = "任务单ID"; grdMain.Columns[HICMOBillNoCol].HeaderText = "任务单号"; grdMain.Columns[HSeOrderInterIDCol].HeaderText = "销售订单主ID"; grdMain.Columns[HSeOrderEntryIDCol].HeaderText = "销售订单子ID"; grdMain.Columns[HSeOrderBillNoCol].HeaderText = "销售订单号"; // grdMain.Columns[HCloseManCol].HeaderText = "行关闭"; grdMain.Columns[HCloseTypeCol].HeaderText = "关闭类型"; grdMain.Columns[HSourceInterIDCol].HeaderText = "源单主内码"; grdMain.Columns[HSourceEntryIDCol].HeaderText = "源单子内码"; grdMain.Columns[HSourceBillNoCol].HeaderText = "源单单号"; grdMain.Columns[HSourceBillTypeCol].HeaderText = "源单类型"; grdMain.Columns[HRelationQtyCol].HeaderText = "关联数量"; grdMain.Columns[HRelationMoneyCol].HeaderText = "关联金额"; //格式化 grdMain.Columns[HProcIDCol].Visible = false; //隐藏列 grdMain.Columns[HCenterIDCol].Visible = false; grdMain.Columns[HCenterNumberCol].Visible = false; grdMain.Columns[HDeptIDCol].Visible = false; grdMain.Columns[HGroupIDCol].Visible = false; grdMain.Columns[HWorkerIDCol].Visible = false; grdMain.Columns[HSourceIDCol].Visible = false; grdMain.Columns[HSourceNumberCol].Visible = false; grdMain.Columns[HTagCol].Visible = false; grdMain.Columns[HGroupNameCol].Visible = false;// "班组"; grdMain.Columns[HGroupNumberCol].Visible = false;//"班组代码"; grdMain.Columns[HWorkerNameCol].Visible = false;//"操作工"; grdMain.Columns[HWorkerNumberCol].Visible = false;//"操作工代码"; grdMain.Columns[HSourceNameCol].Visible = false;//"生产资源"; grdMain.Columns[HWorkingQtyCol].Visible =false;//"在制品数量"; grdMain.Columns[HTimeUnitCol].Visible =false;//"时间单位"; grdMain.Columns[HPlanWorkTimesCol].Visible =false;//"计划加工时间"; grdMain.Columns[HPlanBeginDateCol].Visible =false;//"计划开工日期"; grdMain.Columns[HPlanEndDateCol].Visible =false;//"计划完工日期"; grdMain.Columns[HICMOInterIDCol].Visible =false;//"任务单ID"; grdMain.Columns[HICMOBillNoCol].Visible =false;//"任务单号"; grdMain.Columns[HSeOrderInterIDCol].Visible =false;//"销售订单主ID"; grdMain.Columns[HSeOrderEntryIDCol].Visible =false;//"销售订单子ID"; grdMain.Columns[HSeOrderBillNoCol].Visible =false;//"销售订单号"; // grdMain.Columns[HCloseManCol].Visible =false;//"行关闭"; grdMain.Columns[HCloseTypeCol].Visible =false;//"关闭类型"; //grdMain.Columns[HSourceInterIDCol].Visible =false;//"源单主内码"; //grdMain.Columns[HSourceEntryIDCol].Visible =false;//"源单子内码"; //grdMain.Columns[HSourceBillNoCol].Visible =false;//"源单单号"; //grdMain.Columns[HSourceBillTypeCol].Visible =false;//"源单类型"; //设置可编辑列 string sAllowCol = HProcNoCol.ToString() + "," + HProcNameCol.ToString() + "," + HProcNumberCol.ToString() + "," + HWorkRemarkCol.ToString() + "," + HCenterNameCol.ToString() + "," + HDeptNameCol.ToString() + "," + HDeptNumberCol.ToString() + "," + HGroupNameCol.ToString() + "," + HGroupNumberCol.ToString() + "," + HWorkerNameCol.ToString() + "," + HWorkerNumberCol.ToString() + "," + HSourceNameCol.ToString() + "," + HQtyCol.ToString() + "," + HWorkingQtyCol.ToString() + "," + HTimeUnitCol.ToString() + "," + HPlanWorkTimesCol.ToString() + "," + HPlanBeginDateCol.ToString() + "," + HPlanEndDateCol.ToString() + "," + HICMOInterIDCol.ToString() + "," + HICMOBillNoCol.ToString() + "," + HSeOrderInterIDCol.ToString() + "," + HSeOrderEntryIDCol.ToString() + "," + HSeOrderBillNoCol.ToString(); //设置合计列 string sTotalCol = HQtyCol.ToString(); // DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol,oSumGrid); } //公式重算 private void RowCount(int sRow, int sTag) { if (sTag == 0) { //金额列=数量*单价 //double sMoney = 0; //sMoney = ClsPub.isDoule(grdMain.get_TextMatrix(sRow, HPriceCol)) * ClsPub.isDoule(grdMain.get_TextMatrix(sRow, HQtyCol)); //grdMain.set_TextMatrix(sRow, HMoneyCol, sMoney.ToString()); grdMain.Rows[sRow].Cells[HQtyCol].Value = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value, 2); grdMain.Rows[sRow].Cells[HWorkingQtyCol].Value = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HWorkingQtyCol].Value, 2); if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) < ClsPub.isDoule(grdMain.Rows[sRow].Cells[HRelationQtyCol].Value)) MessageBox.Show("第" + sRow.ToString()+"行小于关联数量"); } else { //单价列=金额/数量 double sMoney = 0; } } //核对选择的内容 public bool CheckGridCell(Cell oCell) { int Row; int Col; Row = oCell.Row; Col = oCell.Col; //if (ClsPub.isStrNull(grdMain.get_TextMatrix(Row, HTagCol)) != "*") //{ // return true; //} //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone; //判断选中列 if (Col == HProcIDCol) // { //ClsGy_MaterialHlp oMate = new ClsGy_MaterialHlp(); //if (oMate.GetInfoByID(ClsPub.isLong(grdMain.Rows[Row].Cells[HMaterIDCol].Value))) //{ // grdMain.Rows[Row].Cells[HMaterIDCol].Value = oMate.HItemID.ToString(); // grdMain.Rows[Row].Cells[HMaterNumberCol].Value = oMate.HNumber; // grdMain.Rows[Row].Cells[HMaterNameCol].Value = oMate.HName; // //grdMain.Rows[Row].Cells[HMaterModelCol].Value = oMate.HModel; //} //else //{ // grdMain.Rows[Row].Cells[HMaterIDCol].Value = ""; // grdMain.Rows[Row].Cells[HMaterNumberCol].Value = ""; // grdMain.Rows[Row].Cells[HMaterNameCol].Value = ""; // //grdMain.Rows[Row].Cells[HMaterModelCol].Value = ""; return false; //} } //else if (Col == HEmpIDCol) // //{ //ClsGy_UnitHlp oUn = new ClsGy_UnitHlp(); //if (oUn.GetInfoByID(ClsPub.isLong(grdMain.Rows[Row].Cells[HUnitIDCol]))) //{ // grdMain.Rows[Row].Cells[HUnitIDCol].Value = oUn.HItemID.ToString(); // grdMain.Rows[Row].Cells[HUnitNameCol].Value = oUn.HName; //} //else //{ // grdMain.Rows[Row].Cells[HUnitIDCol].Value = ""; // grdMain.Rows[Row].Cells[HUnitNameCol].Value = ""; //return false; //} //} else //其他列 { } // // grdMain.Rows[Row].Cells[HTagCol].Value = "*"; oSumGrid.EditStatus = false; return true; } //是否是空行 private bool IsNullRow(int Row) { return DBUtility.Xt_BaseBillFun.IsNullRow(Row, HProcIDCol,grdMain); } //'判断网格行的录入是否正确 private bool CheckGridRow(int Row) { Cell oCell = new Cell(); int c = 0; //if (ClsPub.isStrNull(grdMain.get_TextMatrix(Row, HTagCol)) != "*") //{ // return true; //} // for (c = 0; c < grdMain.ColumnCount; c++) { oCell.Row = Row; oCell.Col = c; //if (!CheckGridCell(oCell)) // return false; } return true; } //帮助函数 private void Sub_GridKey(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit) { //定义基础资料类 DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); DAL.ClsGy_WorkCenter_View oWork = new DAL.ClsGy_WorkCenter_View(); DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View(); DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); DAL.ClsGy_Source_View oSour = new DAL.ClsGy_Source_View(); if (!grdStatus) { return; } //if (oSumGrid.FindAllowEditCol(sCol)) //{ oSumGrid.EditStatus = true; //} //else //{ // return; //} switch (sKeyCode) { case 118: //F7 { switch (sCol) { case HProcNumberCol: oProc.WherePart = ""; if (oProc.RefreshView()) { grdMain.Rows[sRow].Cells[HProcIDCol].Value = oProc.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HProcNumberCol].Value = oProc.oModel.HNumber; grdMain.Rows[sRow].Cells[HProcNameCol].Value = oProc.oModel.HName; EditingControl.Text = oProc.oModel.HNumber; } else { grdMain.Rows[sRow].Cells[HProcIDCol].Value = 0; grdMain.Rows[sRow].Cells[HProcNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HProcNameCol].Value = ""; } break; case HCenterNameCol: oWork.WherePart = ""; if (oWork.RefreshView()) { grdMain.Rows[sRow].Cells[HCenterIDCol].Value = oWork.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HCenterNumberCol].Value = oWork.oModel.HNumber; grdMain.Rows[sRow].Cells[HCenterNameCol].Value = oWork.oModel.HName; EditingControl.Text = oWork.oModel.HName; } else { grdMain.Rows[sRow].Cells[HCenterIDCol].Value = 0; grdMain.Rows[sRow].Cells[HCenterNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HCenterNameCol].Value = ""; } break; case HDeptNumberCol: oDept.WherePart = ""; if (oDept.RefreshView()) { grdMain.Rows[sRow].Cells[HDeptIDCol].Value = oDept.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HDeptNumberCol].Value = oDept.oModel.HNumber; grdMain.Rows[sRow].Cells[HDeptNameCol].Value = oDept.oModel.HName; EditingControl.Text = oDept.oModel.HNumber; } else { grdMain.Rows[sRow].Cells[HDeptIDCol].Value = 0; grdMain.Rows[sRow].Cells[HDeptNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HDeptNameCol].Value = ""; } break; case HGroupNumberCol: oGroup.WherePart = ""; if (oGroup.RefreshView()) { grdMain.Rows[sRow].Cells[HGroupIDCol].Value = oGroup.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HGroupNumberCol].Value = oGroup.oModel.HNumber; grdMain.Rows[sRow].Cells[HGroupNameCol].Value = oGroup.oModel.HName; EditingControl.Text = oGroup.oModel.HNumber; } else { grdMain.Rows[sRow].Cells[HGroupIDCol].Value = 0; grdMain.Rows[sRow].Cells[HGroupNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HGroupNameCol].Value = ""; } break; case HWorkerNumberCol: oEmp.WherePart = ""; if (oEmp.RefreshView()) { grdMain.Rows[sRow].Cells[HWorkerIDCol].Value = oEmp.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HWorkerNumberCol].Value = oEmp.oModel.HNumber; grdMain.Rows[sRow].Cells[HWorkerNameCol].Value = oEmp.oModel.HName; EditingControl.Text = oEmp.oModel.HNumber; } else { grdMain.Rows[sRow].Cells[HWorkerIDCol].Value = 0; grdMain.Rows[sRow].Cells[HWorkerNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HWorkerNameCol].Value = ""; } break; case HSourceNameCol: oSour.WherePart = ""; if (oSour.RefreshView()) { grdMain.Rows[sRow].Cells[HSourceIDCol].Value = oSour.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HSourceNumberCol].Value = oSour.oModel.HNumber; grdMain.Rows[sRow].Cells[HSourceNameCol].Value = oSour.oModel.HName; EditingControl.Text = oSour.oModel.HNumber; } else { grdMain.Rows[sRow].Cells[HSourceIDCol].Value = 0; grdMain.Rows[sRow].Cells[HSourceNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HSourceNameCol].Value = ""; } break; default: break; } break; } case 117: //F6 { switch (sCol) { default: break; } break; } default: break; } } //选原单 private void cmdSourceBillNo_Click(object sender, EventArgs e) { //if (cmbSourceBillType.Text.Trim() == "生产派工单") //幻 //{ // string sWhere = " and HDeptID=" + DBUtility.ClsPub.isLong(txtHDeptID.Tag).ToString(); // DAL.Cls_S_Sc_ICMOSortBill oSc_ICMOSortBill = new DAL.Cls_S_Sc_ICMOSortBill(); // if (oSc_ICMOSortBill.Refresh(sWhere)) //选择原单 // { // FillSelectData(oSc_ICMOSortBill.oBillSelectColl); // } //} //else //{ //} } // private void FillSelectData(List oList) { DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); oSumGrid.Changelock = true; initGrid(); //int i = -1; //foreach (DBUtility.BillSelect oSelectRow in oList) //{ // i = i + 1; // //单 // if (oSelectRow.BillType == "3715") // { // grdMain.Rows.Add(); // grdMain.Rows[i].Cells[HTagCol].Value = "*"; // //得到信息 // //Ds = oCn.RunProcReturn("select * from h_v_K3_ICMOProc where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_K3_ICMOProc"); // //Ds = oCn.RunProcReturn("select * from h_v_K3_ICMOProcByMaterType where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_K3_ICMOProcByMaterType"); // Ds = oCn.RunProcReturn("select * from h_v_Sc_ProcessPlanList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID + " order by hsubid desc", "h_v_Sc_ProcessPlanList"); // //写入信息 // Sub_WriteInForm(Ds.Tables[0], oList.Count-i-1); // } // // //} if (oList.Count > 0) { PlanNoCount = 0; Ds = oCn.RunProcReturn("select * from h_v_Sc_ProcessPlanList where hmainid=" + oList[0].BillMainID + " order by hsubid", "h_v_Sc_ProcessPlanList"); for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { Sub_WriteInForm(Ds.Tables[0], i); PlanNoCount++; } for (int j = 0; j < grdMain.RowCount; j++) { string s = ""; s = "GXJH" + Convert.ToString(ClsPub.isLong(this.txtHBillNo.Tag) * 10000 + PlanNoCount); if (s == DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].Value)) PlanNoCount++; } } // oSumGrid.Changelock = false; DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } //根据TABLE写入界面 private void Sub_WriteInForm2(DataTable oTable, int i) { ////加载表头 txtHMaterID.Tag = ClsPub.isInt(oTable.Rows[i]["HMaterID"].ToString()); txtHMaterID.Text = oTable.Rows[i]["物料名称"].ToString(); txtHMaterNumber.Text = oTable.Rows[i]["物料代码"].ToString(); txtHMaterModel.Text = oTable.Rows[i]["规格型号"].ToString(); txtHUnitID.Tag = ClsPub.isInt(oTable.Rows[i]["HUnitID"].ToString()); txtHUnitID.Text = oTable.Rows[i]["计量单位"].ToString(); txtHUnitNumber.Text = oTable.Rows[i]["计量单位代码"].ToString(); dtpHPlanBeginDate.Value = ClsPub.isDate(oTable.Rows[i]["计划开工日期"].ToString()); dtpHPlanEndDate.Value = ClsPub.isDate(oTable.Rows[i]["计划完工日期"].ToString()); txtHICMOBillNo.Text = oTable.Rows[i]["单据号"].ToString(); ////加载表体 grdMain.Rows[i].Cells[HTagCol].Value = "*"; // grdMain.Rows[i].Cells[HCenterIDCol].Value = oTable.Rows[i]["Hcenterid"].ToString(); grdMain.Rows[i].Cells[HCenterNumberCol].Value = oTable.Rows[i]["工作中心代码"].ToString(); grdMain.Rows[i].Cells[HCenterNameCol].Value = oTable.Rows[i]["工作中心"].ToString(); grdMain.Rows[i].Cells[HDeptIDCol].Value = oTable.Rows[i]["HDeptID"].ToString(); grdMain.Rows[i].Cells[HDeptNumberCol].Value = oTable.Rows[i]["部门代码"].ToString(); grdMain.Rows[i].Cells[HDeptNameCol].Value = oTable.Rows[i]["部门"].ToString(); grdMain.Rows[i].Cells[HProcNoCol].Value = oTable.Rows[i]["工序号"].ToString(); grdMain.Rows[i].Cells[HProcIDCol].Value = oTable.Rows[i]["hprocid"].ToString(); grdMain.Rows[i].Cells[HProcNumberCol].Value = oTable.Rows[i]["工序代码"].ToString(); grdMain.Rows[i].Cells[HProcNameCol].Value = oTable.Rows[i]["工序名称"].ToString(); grdMain.Rows[i].Cells[HBillNoCol].Value = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true); grdMain.Rows[i].Cells[HPlanBeginDateCol].Value = oTable.Rows[i]["计划开工日期"].ToString(); grdMain.Rows[i].Cells[HPlanEndDateCol].Value = oTable.Rows[i]["计划完工日期"].ToString(); grdMain.Rows[i].Cells[HQtyCol].Value = oTable.Rows[i]["任务数量"].ToString(); grdMain.Rows[i].Cells[HICMOInterIDCol].Value = oTable.Rows[i]["hmainid"].ToString(); grdMain.Rows[i].Cells[HICMOBillNoCol].Value = oTable.Rows[i]["单据号"].ToString(); ////-- grdMain.Rows[i].Cells[HSourceInterIDCol].Value = oTable.Rows[i]["hmainid"].ToString(); grdMain.Rows[i].Cells[HSourceEntryIDCol].Value = oTable.Rows[i]["hsubid"].ToString(); grdMain.Rows[i].Cells[HSourceBillTypeCol].Value = oTable.Rows[i]["hbilltype"].ToString(); grdMain.Rows[i].Cells[HSourceBillNoCol].Value = oTable.Rows[i]["单据号"].ToString(); } private void Sub_WriteInForm(DataTable oTable, int i) { ////加载表头 grdMain.Rows.Add(); grdMain.Rows[i].Cells[HTagCol].Value = "*"; txtHMaterID.Tag = ClsPub.isInt(oTable.Rows[i]["HMaterID"].ToString()); txtHMaterID.Text = oTable.Rows[i]["物料名称"].ToString(); txtHMaterNumber.Text = oTable.Rows[i]["物料代码"].ToString(); txtHMaterModel.Text = oTable.Rows[i]["规格型号"].ToString(); txtHUnitID.Tag = ClsPub.isInt(oTable.Rows[i]["HUnitID"].ToString()); txtHUnitID.Text = oTable.Rows[i]["计量单位"].ToString(); txtHUnitNumber.Text = oTable.Rows[i]["计量单位代码"].ToString(); dtpHPlanBeginDate.Value = ClsPub.isDate(oTable.Rows[i]["计划开工日期"].ToString()); dtpHPlanEndDate.Value = ClsPub.isDate(oTable.Rows[i]["计划完工日期"].ToString()); txtHBillNo.Tag = ClsPub.isInt(oTable.Rows[i]["Hmainid"].ToString()); txtHBillNo.Text = oTable.Rows[i]["单据号"].ToString(); txtHICMOBillNo.Tag = ClsPub.isInt(oTable.Rows[i]["hicmointerid"].ToString()); txtHICMOBillNo.Text = oTable.Rows[i]["任务单号"].ToString(); txtHPlanQty.Text = ClsPub.isDoule(oTable.Rows[i]["生产数量"].ToString(),2).ToString(); txtHMaker.Text = oTable.Rows[i]["制单人"].ToString(); txtHMakeDate.Text = oTable.Rows[i]["制单日期"].ToString(); txtHUpDater.Text = oTable.Rows[i]["审核人"].ToString(); txtHUpDateDate.Text = oTable.Rows[i]["审核日期"].ToString(); ////加载表体 grdMain.Rows[i].Cells[HTagCol].Value = "*"; // //grdMain.Rows[i].Cells[HMaterIDCol].Value = ClsPub.isInt(oTable.Rows[i]["HMaterID"].ToString()); //grdMain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[i]["物料名称"].ToString(); //grdMain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[i]["物料代码"].ToString(); //grdMain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[i]["规格型号"].ToString(); //grdMain.Rows[i].Cells[HUintIDCol].Value = ClsPub.isInt(oTable.Rows[i]["HUnitID"].ToString()); //grdMain.Rows[i].Cells[HUintNameCol].Value = oTable.Rows[i]["计量单位"].ToString(); //grdMain.Rows[i].Cells[HUintNumberCol].Value = oTable.Rows[i]["计量单位代码"].ToString(); //grdMain.Rows[i].Cells[HPlanQtyIDCol].Value = ClsPub.isDoule(oTable.Rows[i]["计划数量"]); // grdMain.Rows[i].Cells[HCenterIDCol].Value = oTable.Rows[i]["Hcenterid"].ToString(); grdMain.Rows[i].Cells[HCenterNumberCol].Value = oTable.Rows[i]["工作中心代码"].ToString(); grdMain.Rows[i].Cells[HCenterNameCol].Value = oTable.Rows[i]["工作中心"].ToString(); grdMain.Rows[i].Cells[HDeptIDCol].Value = oTable.Rows[i]["HDeptID"].ToString(); grdMain.Rows[i].Cells[HDeptNumberCol].Value = oTable.Rows[i]["加工车间代码"].ToString(); grdMain.Rows[i].Cells[HDeptNameCol].Value = oTable.Rows[i]["加工车间"].ToString(); grdMain.Rows[i].Cells[HProcNoCol].Value = ClsPub.isInt(oTable.Rows[i]["hsubid"].ToString()) + 1; grdMain.Rows[i].Cells[HProcIDCol].Value = oTable.Rows[i]["hprocid"].ToString(); grdMain.Rows[i].Cells[HProcNumberCol].Value = oTable.Rows[i]["工序代码"].ToString(); grdMain.Rows[i].Cells[HProcNameCol].Value = oTable.Rows[i]["工序"].ToString(); grdMain.Rows[i].Cells[HBillNoCol].Value = oTable.Rows[i]["工序计划单号"].ToString(); grdMain.Rows[i].Cells[HPlanBeginDateCol].Value = oTable.Rows[i]["计划开工日期"].ToString(); grdMain.Rows[i].Cells[HPlanEndDateCol].Value = oTable.Rows[i]["计划完工日期"].ToString(); grdMain.Rows[i].Cells[HQtyCol].Value = ClsPub.isDoule(oTable.Rows[i]["计划数量"]);// -ClsPub.isDoule(oTable.Rows[i]["关联数量"]); grdMain.Rows[i].Cells[HRelationQtyCol].Value = oTable.Rows[i]["关联数量"].ToString(); grdMain.Rows[i].Cells[HICMOInterIDCol].Value = oTable.Rows[i]["hicmointerid"].ToString(); grdMain.Rows[i].Cells[HICMOBillNoCol].Value = oTable.Rows[i]["任务单号"].ToString(); ////-- grdMain.Rows[i].Cells[HSourceInterIDCol].Value = oTable.Rows[i]["源单主内码"].ToString(); grdMain.Rows[i].Cells[HSourceEntryIDCol].Value = oTable.Rows[i]["源单子内码"].ToString(); grdMain.Rows[i].Cells[HSourceBillTypeCol].Value = oTable.Rows[i]["源单类型"].ToString(); grdMain.Rows[i].Cells[HSourceBillNoCol].Value = oTable.Rows[i]["源单单号"].ToString(); } //放大镜按钮 private void cmdHMaterID_Click(object sender, EventArgs e) { DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View(); DAL.ClsGy_Unit_View oUnit = new DAL.ClsGy_Unit_View(); if (oMater.RefreshView()) { txtHMaterID.Tag = oMater.omodel.HItemID.ToString(); if (oMater.GetInfoByID(oMater.omodel.HItemID)) { txtHMaterNumber.Text = oMater.omodel.HNumber; txtHMaterID.Text = oMater.omodel.HName; txtHMaterModel.Text = oMater.omodel.HModel; if (oUnit.GetInfoByID(oMater.omodel.HUnitID)) { txtHUnitID.Tag = oUnit.omodel.HItemID.ToString(); txtHUnitID.Text = oUnit.omodel.HName; txtHUnitNumber.Text = oUnit.omodel.HNumber; } else { txtHUnitID.Text = ""; txtHUnitNumber.Text = ""; } } else { txtHMaterID.Text = ""; txtHMaterNumber.Text = ""; txtHMaterModel.Text = ""; txtHUnitID.Text = ""; txtHUnitNumber.Text = ""; } } else { txtHMaterID.Text = ""; txtHMaterNumber.Text = ""; txtHMaterModel.Text = ""; } } private void cmdHUnitID_Click(object sender, EventArgs e) { DAL.ClsGy_Unit_View oUnit = new DAL.ClsGy_Unit_View(); if (oUnit.RefreshView()) { this.txtHUnitID.Text = oUnit.oModel.HName; this.txtHUnitID.Tag = oUnit.oModel.HItemID.ToString(); this.txtHUnitNumber.Text = oUnit.oModel.HNumber; } else { this.txtHUnitID.Text = ""; this.txtHUnitNumber.Text = ""; } } //网格编辑前判断 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_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); RowCount(e.RowIndex, 0); //计算 金额 单价 // if (this.EditingControl != null) //释放事件 { EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown); this.EditingControl = null; } } DataGridViewTextBoxEditingControl EditingControl; private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e) { // if (!grdStatus) { return; } DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // //if (oSumGrid.Changelock) // return; //if(oSumGrid.EditStatus) //{ if (!CheckGridRow(oSumGrid.OldCell.Row)) return; //} } private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } 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_Scroll(object sender, ScrollEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); oSumGrid.DisplayCurRow(); } #endregion #region //打印设置 GridppReport Report; //预览 private void yl_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()// { Report.FieldByName("单据号").AsString = txtHBillNo.Text; Report.FieldByName("日期").AsString = dtpHDate.Value.ToString(); Report.FieldByName("业务员").AsString = txtHMaterID.Text; Report.FieldByName("内部单据号").AsString = txtHInnerBillNo.Text; Report.FieldByName("表头备注").AsString = txtHRemark.Text; } private void ReportFetchRecordByDataTable() { //BLL.Utility.FillRecordToReport(Report, grdMain, grdPrint, HProcIDCol); } #endregion private void txtHMaterID_TextChanged(object sender, EventArgs e) { if (txtHMaterID.Text.Trim() == "") { txtHMaterID.Tag = "0"; txtHMaterNumber.Text = ""; } } private void txtHUnitID_TextChanged(object sender, EventArgs e) { if (txtHUnitID.Text.Trim() == "") { txtHUnitID.Tag = "0"; txtHUnitNumber.Text = ""; } } private void cmdHICMO_Click(object sender, EventArgs e) { //string sWhere = " "; //DAL.Cls_S_K3_ICMOProc oK3_ICMOBill = new DAL.Cls_S_K3_ICMOProc(); //if (oK3_ICMOBill.Refresh(sWhere)) //选择原单 //{ // FillSelectData(oK3_ICMOBill.oBillSelectColl); //} string sWhere = ""; DAL.Cls_S_Sc_ProcessPlan oSc_ProcessPlan = new DAL.Cls_S_Sc_ProcessPlan(); sWhere = oSc_ProcessPlan.sCondtion; if (oSc_ProcessPlan.Refresh2(sWhere)) //选择原单 { FillSelectData(oSc_ProcessPlan.oBillSelectColl); } } private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e) { this.Sub_CloseBill(); } private void 反关闭ToolStripMenuItem_Click(object sender, EventArgs e) { this.Sub_Cancel(); } private void 审核ToolStripMenuItem_Click(object sender, EventArgs e) { this.Sub_CheckBill(); } private void 反审核ToolStripMenuItem_Click(object sender, EventArgs e) { this.Sub_AbandonCheck(); } private void 作废ToolStripMenuItem_Click(object sender, EventArgs e) { this.Sub_Cancelltion(); } private void 撤销作废ToolStripMenuItem_Click(object sender, EventArgs e) { this.Sub_AbandonCancelltion(); } private void 隐藏列设置ToolStripMenuItem_Click(object sender, EventArgs e) { BLL.Gy_GridView_Hide oHide = new BLL.Gy_GridView_Hide(); oHide.KeyItem = this.Name; oHide.oGrd = grdMain; oHide.ShowDialog(); // DBUtility.ClsPub.HideGridView(grdMain, Name, ClsPub.AppPath);//设置隐藏列 } } }