using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using gregn6Lib; using Pub_Class; using System.Threading; namespace WarM { public partial class K3_BarCodeBill : Form { public K3_BarCodeBill() { InitializeComponent(); } //定义 public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HMainIDCol = 2; public const Int16 HSubIDCol = 3; public const Int16 HBillNoCol = 4; public const Int16 HBillTypeCol = 5; public const Int16 HMaterIDCol = 6; public const Int16 HMaterNumberCol = 7; public const Int16 HMaterNameCol = 8; public const Int16 HPinfanCol = 9; public const Int16 HMaterModelCol = 10; public const Int16 HModelCol = 11; public const Int16 HAuxPropIDCol = 12; public const Int16 HAuxPropNumberCol = 13; public const Int16 HAuxPropNameCol = 14; public const Int16 HUnitIDCol = 15; public const Int16 HUnitNumberCol = 16; public const Int16 HUnitNameCol = 17; public const Int16 HBarCodeTypeCol = 18; public const Int16 HBatchManagerCol = 19; public const Int16 HBatchNoCol = 20; public const Int16 HQtyCol = 21; public const Int16 HMinQtyCol = 22; public const Int16 HBQtyCol = 23; public const Int16 HDeptIDCol = 24; public const Int16 HDeptNumberCol = 25; public const Int16 HDeptNameCol = 26; public const Int16 HDateCol = 27; public const Int16 HSupIDCol = 28; public const Int16 HSupNumberCol = 29; public const Int16 HSupNameCol = 30; public const Int16 HSourceInterIDCol = 31; public const Int16 HSourceEntryIDCol = 32; public const Int16 HSourceBillNoCol = 33; public const Int16 HSourceBillTypeCol = 34; public const Int16 HInstructIDCol = 35; public const Int16 HInstructNoCol = 36; public const Int16 HSeOrderBillIDCol = 37; public const Int16 HSeOrderBillNoCol = 38; public const Int16 HWhIDCol = 39; public const Int16 HWhNumberCol = 40; public const Int16 HWhNameCol = 41; public const Int16 HSPIDCol = 42; public const Int16 HSPNumberCol = 43; public const Int16 HSPNameCol = 44; public const Int16 HinitQtyCol = 45; public const Int16 HRemarkCol = 46; public const Int16 HPinfanBarCodeCol = 47; public Int16 HSelectCol = 0; public Int16 HSno2Col = 1; public Int16 HTMCol = 2; public Int16 HBarCodeType2Col = 3; public Int16 HMaterID2Col = 4; public Int16 HMaterNumber2Col = 5; public Int16 HMaterName2Col = 6; public Int16 HPinfan2Col = 7; public Int16 HMaterModel2Col = 8; public Int16 HModel2Col = 9; public Int16 HAuxPropID2Col = 10; public Int16 HAuxPropNumber2Col = 11; public Int16 HAuxPropName2Col = 12; public Int16 HBatchNo2Col = 13; public Int16 HUnitID2Col = 14; public Int16 HUnitNumber2Col = 15; public Int16 HUnitName2Col = 16; public Int16 HQty2Col = 17; public Int16 HWeiCol = 18; public Int16 HPrintCol = 19; public Int16 HDeptID2Col = 20; public Int16 HDeptNumber2Col = 21; public Int16 HDeptName2Col = 22; public Int16 HDate2Col = 23; public Int16 HBarcodeNoCol = 24; public Int16 HBarcodeQtysCol = 25; public Int16 HSupID2Col = 26; public Int16 HSupNumber2Col = 27; public Int16 HSupName2Col = 28; public Int16 HSourceInterID2Col = 29; public Int16 HSourceEntryID2Col = 30; public Int16 HSourceBillNo2Col = 31; public Int16 HSourceBillType2Col = 32; public Int16 HInstructID2Col = 33; public Int16 HInstructNo2Col = 34; public Int16 HSeOrderBillID2Col = 35; public Int16 HSeOrderBillNo2Col = 36; public Int16 HWhID2Col = 37; public Int16 HWhNumber2Col = 38; public Int16 HWhName2Col = 39; public Int16 HSPID2Col = 40; public Int16 HSPNumber2Col = 41; public Int16 HSPName2Col = 42; public Int16 HRemark2Col = 43; public Int16 HPinfanBarCode2Col = 44; // public string ModName = "85"; public string ModCaption = "条码生成"; public bool BillChange; // public DBUtility.ClsPub.Enum_BillStatus BillStatus; public Int64 KeyID; public bool grdStatus; //public DAL.ClsK3_BarCodeBill BillNew =new DAL.ClsK3_BarCodeBill(); //public DAL.ClsK3_BarCodeBill BillOld = new DAL.ClsK3_BarCodeBill(); ClsGridViewSum oSumGrid = new ClsGridViewSum(); public int selectRow = 0; public int selectRow2 = 0; //------------------------------------------------------------------------- #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 = ""; 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) //{ // if (BillOld.DeleteBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) != true) // { // BillChange = true; // MessageBox.Show("删除失败,原因:" + ClsPub.sExeReturnInfo, "提示"); // return; // } // MessageBox.Show("删除成功", "提示"); // BillOld = new DAL.ClsK3_BarCodeBill(); // 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); DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub"); } //增行按钮 private void AddRow_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.AddRow(oSumGrid); } //删行按纽 private void DelRow_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.DelRow(oSumGrid); } private void mrlk_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub"); } //离开单元格 private void grdMain_LeaveCell(object sender, EventArgs e) { oSumGrid.LeaveCell(); } //网格单元格变化事件 private void grdMain_RowColChange(object sender, EventArgs e) { // if (!grdStatus) { return; } DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // //if (oSumGrid.Changelock) // return; //if(oSumGrid.EditStatus) //{ if (!CheckGridRow(oSumGrid.OldCell.Row)) return; //} } //放弃 编辑 private void Sub_AbandonBill() { if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew || BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify) { if (MessageBox.Show("是否放弃对当前物料进行条码生成操作?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { this.Sub_AddBill(); } } //MessageBox.Show("条码打印完毕!"); } private void K3_BarCodeBill_Paint(object sender, PaintEventArgs e)//画线 { Graphics g = this.panel2.CreateGraphics(); Pen p = new Pen(Color.Gray); p.Width = 1; g.DrawLine(p, new Point(txtHMaker.Left, txtHMaker.Top + txtHMaker.Height), new Point(txtHMaker.Left + txtHMaker.Width, txtHMaker.Top + txtHMaker.Height)); g.DrawLine(p, new Point(txtHMakeDate.Left, txtHMakeDate.Top + txtHMakeDate.Height), new Point(txtHMakeDate.Left + txtHMakeDate.Width, txtHMakeDate.Top + txtHMakeDate.Height)); // g.DrawLine(p, new Point(txtHChecker.Left, txtHChecker.Top + txtHChecker.Height), new Point(txtHChecker.Left + txtHChecker.Width, txtHChecker.Top + txtHChecker.Height)); g.DrawLine(p, new Point(txtHCheckDate.Left, txtHCheckDate.Top + txtHCheckDate.Height), new Point(txtHCheckDate.Left + txtHCheckDate.Width, txtHCheckDate.Top + txtHCheckDate.Height)); // g.DrawLine(p, new Point(txtHCloseMan.Left, txtHCloseMan.Top + txtHCloseMan.Height), new Point(txtHCloseMan.Left + txtHCloseMan.Width, txtHCloseMan.Top + txtHCloseMan.Height)); g.DrawLine(p, new Point(txtHCloseDate.Left, txtHCloseDate.Top + txtHCloseDate.Height), new Point(txtHCloseDate.Left + txtHCloseDate.Width, txtHCloseDate.Top + txtHCloseDate.Height)); // g.DrawLine(p, new Point(this.txtHDeleteMan.Left, txtHDeleteMan.Top + txtHDeleteMan.Height), new Point(txtHDeleteMan.Left + txtHDeleteMan.Width, txtHDeleteMan.Top + txtHDeleteMan.Height)); g.DrawLine(p, new Point(txtHDeleteDate.Left, txtHDeleteDate.Top + txtHDeleteDate.Height), new Point(txtHDeleteDate.Left + txtHDeleteDate.Width, txtHDeleteDate.Top + txtHDeleteDate.Height)); // g.DrawLine(p, new Point(this.txtHUpDater.Left, txtHUpDater.Top + txtHUpDater.Height), new Point(txtHUpDater.Left + txtHUpDater.Width, txtHUpDater.Top + txtHUpDater.Height)); g.DrawLine(p, new Point(txtHUpDateDate.Left, txtHUpDateDate.Top + txtHUpDateDate.Height), new Point(txtHUpDateDate.Left + txtHUpDateDate.Width, txtHUpDateDate.Top + txtHUpDateDate.Height)); //控件位置设置 } //控件位置 private void Sub_ControlLocation() { //gbUp.Width = P1.Width - 20; //gbUp.Left = 10; //gbUp.Height = P1.Height - 35; //gbUp.Top = 30; } //窗体加载 private void K3_BarCodeBill_Load(object sender, EventArgs e) { //打印初始化 dtpHDate.Value = DateTime.Today; oSumGrid.NoCol = HSnoCol; oSumGrid.ogrdMain = grdMain; oSumGrid.oGridsum = grdSum; this.Text = ModCaption; this.lblCaption.Text = ModCaption; } //首张 private void Sub_First() { //BillStatus =DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; //BillOld = new DAL.ClsK3_BarCodeBill(); //if (BillOld.GetFirstBill(ref ClsPub.sExeReturnInfo)) //{ // this.Sub_ShowBill(); //} //else //没有找到则 变为新增状态 //{ // this.Sub_AddBill(); //} } //上张 private void Sub_Prev() { //BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; //if (BillOld.GetPrevousBill(ref ClsPub.sExeReturnInfo,txtHBillNo.Text)) //{ // this.Sub_ShowBill(); //} } //下张 private void Sub_Next() { //BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; //if (BillOld.GetNextBill(ref ClsPub.sExeReturnInfo, txtHBillNo.Text)) //{ // this.Sub_ShowBill(); //} } //末张 private void Sub_Last() { //BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; //BillOld = new DAL.ClsK3_BarCodeBill(); //if (BillOld.GetLastBill(ref ClsPub.sExeReturnInfo)) //{ // this.Sub_ShowBill(); //} } //审核单据 private void Sub_CheckBill() { //if (BillOld.CheckBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHChecker.Text = ClsPub.CurUserName; // txtHCheckDate.Text = BillOld.omodel.HCheckDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("审核失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反审单据 private void Sub_AbandonCheck() { //if (BillOld.AbandonCheck(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHChecker.Text = ""; // txtHCheckDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("反审核失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //关闭单据 private void Sub_CloseBill() { //if (BillOld.CloseBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHCloseMan.Text = ClsPub.CurUserName; // txtHCloseDate.Text = BillOld.omodel.HCloseDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("关闭失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反关闭单据 private void Sub_Cancel() { //if (BillOld.CancelClose(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHCloseMan.Text = ""; // txtHCloseDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("恢复失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //作废单据 private void Sub_Cancelltion() { //if (BillOld.Cancelltion(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // this.txtHDeleteMan.Text = ClsPub.CurUserName; // this.txtHDeleteDate.Text = BillOld.omodel.HDeleteDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("作废失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反作废 private void Sub_AbandonCancelltion() { //if (BillOld.AbandonCancelltion(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // this.txtHDeleteMan.Text = ""; // this.txtHDeleteDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("作废失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //新增按纽 private void xz_Click(object sender, EventArgs e) { this.Sub_AddBill(); } //修改按纽 private void xg_Click(object sender, EventArgs e) { this.Sub_EditBill(); } //删除按钮 private void sc_Click(object sender, EventArgs e) { this.Sub_DeleteBill(); } //保存按钮 private void bc_Click(object sender, EventArgs e) { this.Sub_SaveBill(); } //放弃按钮 private void fq_Click(object sender, EventArgs e) { grdMain.Columns[HBillNoCol].ReadOnly = false; this.Sub_AbandonBill(); tabControl1.SelectedIndex = 0; } //审核按钮 private void sh_Click(object sender, EventArgs e) { this.Sub_CheckBill(); } //放弃审核按钮 private void qsh_Click(object sender, EventArgs e) { this.Sub_AbandonCheck(); } //关闭按钮 private void gb_Click(object sender, EventArgs e) { this.Sub_CloseBill(); } //恢复按钮 private void hf_Click(object sender, EventArgs e) { this.Sub_Cancel(); } //作废按钮 private void zf_Click(object sender, EventArgs e) { this.Sub_Cancelltion(); } //反作废按钮 private void zc_Click(object sender, EventArgs e) { this.Sub_AbandonCancelltion(); } //首张单据按钮 private void sz_Click(object sender, EventArgs e) { this.Sub_First(); } //上一张按钮 private void syz_Click(object sender, EventArgs e) { this.Sub_Prev(); } //下一张按钮 private void xyz_Click(object sender, EventArgs e) { this.Sub_Next(); } //末张按钮 private void mz_Click(object sender, EventArgs e) { this.Sub_Last(); } //退出按钮 private void tc_Click(object sender, EventArgs e) { this.Close(); } //窗体尺寸变化时 private void K3_BarCodeBill_Resize(object sender, EventArgs e) { //Sub_ControlLocation(); } //根据编辑状态 设置 控件是否允许录入 private void Sub_LrtextStatus(bool TextEnabled) { if (TextEnabled == true) { //控件全部有效 gbUp.Enabled = true; grdMain.BackColor = ClsPub.EditColor; } else { //控件全部无效 gbUp.Enabled = false; grdMain.BackColor = ClsPub.ViewColor; } } //复制单据 private void Sub_CopyBill() { //this.BillStatus =DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; //this.Sub_OperStatus();//设置TOOLBAR //this.txtHBillNo.Text = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);//得到新单号 //this.txtHBillNo.Enabled = true; //this.txtHBillNo.Focus(); //this.txtHMaker.Text = ClsPub.CurUserName; //this.txtHMakeDate.Text = ClsPub.GetServerDate(-1); //this.txtHChecker.Text = ""; //this.txtHCloseDate.Text = ""; //this.txtHCloseMan.Text = ""; //this.txtHCloseDate.Text = ""; //this.txtHDeleteMan.Text = ""; //this.txtHDeleteDate.Text = ""; //this.txtHUpDater.Text = ""; //this.txtHUpDateDate.Text = ""; } //复制按钮 private void fz_Click(object sender, EventArgs e) { Sub_CopyBill(); } //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(); } DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } //窗体卸载 private void K3_BarCodeBill_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.ClsK3_BarCodeBill(); //this.BillOld = new DAL.ClsK3_BarCodeBill(); this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; this.Sub_OperStatus();//设置TOOLBAR this.Sub_ClearBill();//清空界面 //this.txtHBillNo.Text = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);//得到新单号(缺少函数) 未完成 //this.txtHBillNo.Enabled = true; //this.txtHBillNo.Focus(); } //TOOLBAR状态 按钮是否灰度 public void Sub_OperStatus() { switch (BillStatus) { case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View: //浏览状态 yl.Enabled = true; AddRow.Enabled = false; DelRow.Enabled = false; bc.Enabled = false; fq.Enabled = false; tc.Enabled = true; //未审核 if (txtHChecker.Text.Trim() == "") { //未审核 pic1.Visible = false; pic1.Image = null; // } else if (txtHCloseMan.Text.Trim() == "" && txtHChecker.Text.Trim() != "")//审核未关闭 { // pic1.Visible = true; pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Checked.jpg"); // } else//已关闭 { // pic1.Visible = true; pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Closed.jpg"); // } if (txtHDeleteMan.Text.Trim() == "") { } else //已作废 { AddRow.Enabled = false; DelRow.Enabled = false; bc.Enabled = false; fq.Enabled = false; // pic1.Visible = true; pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Deleted.jpg"); // } Sub_LrtextStatus(false); grdStatus = false; break; case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew: //新增状态 yl.Enabled = true; AddRow.Enabled = true; DelRow.Enabled = true; bc.Enabled = true; fq.Enabled = true; tc.Enabled = true; Sub_LrtextStatus(true); grdStatus = true; //未审核 pic1.Visible = false; pic1.Image = null; // break; case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify: //修改状态 yl.Enabled = true; AddRow.Enabled = true; DelRow.Enabled = true; bc.Enabled = true; fq.Enabled = true; tc.Enabled = true; Sub_LrtextStatus(true); grdStatus = true; //未审核 pic1.Visible = false; pic1.Image = null; // break; } } #endregion #region 读写类 //显示单据 public void Sub_ShowBill() { //DAL.ClsK3_Employee_View oEmp = new DAL.ClsK3_Employee_View(); //DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View(); //DAL.ClsK3_Department_View oDept = new DAL.ClsK3_Department_View(); //DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); //DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View(); //DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); ////判断是否存在单据 //if(BillOld.ShowBill(BillOld.omodel.HInterID,ref ClsPub.sExeReturnInfo)==false ) //{ // MessageBox.Show(ClsPub.sExeReturnInfo, "提示"); // return; //} ////清空 //Sub_ClearBill(); ////grid禁止刷新 ////加载表头 //if (oDept.GetInfoByID(BillOld.omodel.HDeptID)) //{ // this.txtHDeptID.Tag = oDept.omodel.HItemID.ToString().Trim(); // this.txtHDeptID.Text = oDept.omodel.HName; //} //else //{ // this.txtHDeptID.Text = ""; //} ////// //if (oEmp.GetInfoByID(BillOld.omodel.HEmpID)) //{ // this.txtHEmpID.Text = oEmp.omodel.HName; // this.txtHEmpID.Tag = oEmp.omodel.HItemID.ToString().Trim(); //} //else //{ // this.txtHEmpID.Text = ""; //} //// //// //if (oGroup.GetInfoByID(BillOld.omodel.HGroupID)) //{ // this.txtHGroupID.Text = oGroup.omodel.HName; // this.txtHGroupID.Tag = oGroup.omodel.HItemID.ToString().Trim(); //} //else //{ // this.txtHGroupID.Text = ""; //} //// //this.dtpHDate.Value = BillOld.omodel.HDate; //this.txtHBillNo.Text = BillOld.omodel.HBillNo; //this.txtHRemark.Text = BillOld.omodel.HRemark; //// //this.txtHMaker.Text = BillOld.omodel.HMaker; //this.txtHMakeDate.Text = BillOld.omodel.HMakeDate; //this.txtHChecker.Text = BillOld.omodel.HChecker; //this.txtHCheckDate.Text = BillOld.omodel.HCheckDate; //this.txtHCloseMan.Text = BillOld.omodel.HCloseMan; //this.txtHCloseDate.Text = BillOld.omodel.HCloseDate; //this.txtHDeleteMan.Text = BillOld.omodel.HDeleteMan; //this.txtHDeleteDate.Text = BillOld.omodel.HDeleteDate; //this.txtHUpDater.Text = BillOld.omodel.HUpDater; //this.txtHUpDateDate.Text = BillOld.omodel.HUpDateDate; ////加载表体 //int i = 0; //foreach (Model.ClsK3_BarCodeBillSub oSub in BillOld.DetailColl) //{ // if (i >= grdMain.RowCount - 1) // grdMain.Rows.Add(); // grdMain.Rows[i].Cells[HTagCol].Value = "*"; // grdMain.Rows[i].Cells[HMaterIDCol].Value = oSub.HMaterID.ToString(); // if (oMater.GetInfoByID(oSub.HMaterID)) // { // grdMain.Rows[i].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber; // grdMain.Rows[i].Cells[HMaterNameCol].Value = oMater.omodel.HName; // } // else // { // grdMain.Rows[i].Cells[HMaterNumberCol].Value = ""; // grdMain.Rows[i].Cells[HMaterNameCol].Value = ""; // } // // // grdMain.Rows[i].Cells[HUnitIDCol].Value = oSub.HUnitID.ToString(); // if (oUnit.GetInfoByID(oSub.HUnitID)) // { // grdMain.Rows[i].Cells[HUnitNumberCol].Value = oUnit.omodel.HNumber; // grdMain.Rows[i].Cells[HUnitNameCol].Value = oUnit.omodel.HName; // } // else // { // grdMain.Rows[i].Cells[HUnitNameCol].Value = ""; // grdMain.Rows[i].Cells[HUnitNumberCol].Value = ""; // } // // // grdMain.Rows[i].Cells[HSourceIDCol].Value = oSub.HSourceID.ToString(); // if (oSource.GetInfoByID(oSub.HSourceID)) // { // grdMain.Rows[i].Cells[HSourceNumberCol].Value = oSource.omodel.HNumber; // grdMain.Rows[i].Cells[HSourceNameCol].Value = oSource.omodel.HName; // } // else // { // grdMain.Rows[i].Cells[HSourceNameCol].Value = ""; // grdMain.Rows[i].Cells[HSourceNumberCol].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[HEmpNameCol].Value = oEmp.omodel.HName; // } // else // { // grdMain.Rows[i].Cells[HEmpNameCol].Value = ""; // grdMain.Rows[i].Cells[HWorkerNumberCol].Value = ""; // } // // // grdMain.Rows[i].Cells[HTimesCol].Value = oSub.HTimes.ToString(); // grdMain.Rows[i].Cells[HQtyCol].Value = oSub.HQty.ToString(); // grdMain.Rows[i].Cells[HQtyMustCol].Value = oSub.HQtyMust.ToString(); // grdMain.Rows[i].Cells[HBadCountCol].Value = oSub.HBadCount.ToString(); // grdMain.Rows[i].Cells[HWasterQtyCol].Value = oSub.HWasterQty.ToString(); // grdMain.Rows[i].Cells[HRemarkCol].Value = oSub.HRemark; // grdMain.Rows[i].Cells[HICMOBillNoCol].Value = oSub.HICMOBillNo; // grdMain.Rows[i].Cells[HICMOInterIDCol].Value = oSub.HICMOInterID.ToString(); // grdMain.Rows[i].Cells[HSourceBillNoCol].Value = oSub.HSourceBillNo; // grdMain.Rows[i].Cells[HSourceInterIDCol].Value = oSub.HSourceInterID.ToString(); // grdMain.Rows[i].Cells[HSourceEntryIDCol].Value = oSub.HSourceEntryID.ToString(); // grdMain.Rows[i].Cells[HSourceBillTypeCol].Value = oSub.HSourceBillType.Trim(); // grdMain.Rows[i].Cells[HRelationQtyCol].Value = oSub.HRelationQty.ToString(); // grdMain.Rows[i].Cells[HRelationMoneyCol].Value = oSub.HRelationMoney.ToString(); // grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value = oSub.HSeOrderBillNo; // grdMain.Rows[i].Cells[HSeOrderInterIDCol].Value = oSub.HSeOrderInterID.ToString(); // grdMain.Rows[i].Cells[HSeOrderEntryIDCol].Value = oSub.HSeOrderEntryID.ToString(); // i = i + 1; //} ////GRID允许刷新 //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); //// //Sub_OperStatus(); } //单据完整性判断 未完成 private bool Sub_AllowSave() { ////必输项目是否为空 //if (txtHDeptID.Tag.ToString().Trim() == "0") //{ // MessageBox.Show("生产车间没有选择!", "提示"); // return false; //} //if (txtHGroupID.Tag.ToString().Trim() == "0") //{ // MessageBox.Show("班组没有选择!", "提示"); // return false; //} //单据号是否重复 //if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, txtHBillNo.Text.Trim(), BillStatus, BillOld.omodel.HInterID)) //{ // MessageBox.Show("单据号重复!", "提示"); // return false; //} //明细表是否为零行 SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet DS; string HRemark = ""; bool b = false; bool a = false; for (int i = 0; i < grdMain.RowCount; i++) { if (!IsNullRow(i)) { b = true; break; } } if (b == false) { MessageBox.Show("明细行不存在!", "提示"); return false; } for (int j = 0; j < grdMain.Rows.Count; j++) { if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0) { DS = oCn.RunProcReturn("exec h_p_HMaterAuxProp " + grdMain.Rows[j].Cells[HMaterIDCol].Value.ToString(), "h_p_HMaterAuxProp", ref DBUtility.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count != 0 && ClsPub.isLong(grdMain.Rows[j].Cells[HAuxPropIDCol].Value) == 0) { HRemark = HRemark + " 第" + ClsPub.isLong(grdMain.Rows[j].Cells[HSnoCol].Value) + "行,物料" + ClsPub.isStrNull(grdMain.Rows[j].Cells[HMaterNameCol].Value); a = true; } } } if (a == true) { MessageBox.Show(HRemark + " 辅助属性没有选择,不允许生成条码", "提示"); return false; } return true; } //保存单据 private bool Sub_SaveBill() { if (!Sub_AllowSave())//单据完整性判断 { return false; } SaveBarCodeBySingle(); bc.Enabled = false; return true; } private void Sub_SaveBill2() { grdSub.Rows.Clear(); int LSHlen = 6; //流水号长度 int SumLen = 10; //总长度 string TM = ""; //条码 string HNumber = ""; //物料代码 double HSumQty = 0; //产品数量 double HQty = 0; //数量 int HBQty = 0; //箱数量 double HMinQty = 0; //每箱数量 string WeiShu = ""; //尾数 int LSH = 0; //流水号 string LSH2 = ""; //流水号转换成字符 string sDate = ""; //日期 string sYear = ""; //年 string sPeriod = ""; //月 string sDay = ""; //日 int k = 0; int n = 0; DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); Ds = oCn.RunProcReturn("exec GetLSH '" + ClsPub.GetServerDate(0) + "'", "GetLSH"); LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]); for (int j = 0; j < grdMain.Rows.Count; j++) { if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0 && ClsPub.isStrNull(grdMain.Rows[j].Cells[HBarCodeTypeCol].Value) == "批次条码") { //生成流水号 HNumber = grdMain.Rows[j].Cells[HMaterIDCol].Value.ToString(); LSH = LSH + 1; LSH2 = LSH.ToString(); while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0 { LSH2 = "0" + LSH2; } sDate = ClsPub.GetServerDate(0); sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2); sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString(); sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2); sDay = "0" + ClsPub.isDate(sDate).Day.ToString(); sDay = sDay.Substring(sDay.Length - 2, 2); //================================== TM = HNumber + sYear + sPeriod + sDay + LSH2; //条码 HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value); HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); for (int i = k; i < HBQty; i++) { if (HSumQty - HMinQty > 0) { WeiShu = ""; HSumQty = HSumQty - HMinQty; } else { //if (HSumQty == HMinQty) //{ WeiShu = ""; //} //else //{ // WeiShu = "尾数"; //} HMinQty = HSumQty; } if (i + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[i].Cells[HTMCol].Value = TM; grdSub.Rows[i].Cells[HBarCodeType2Col].Value = grdMain.Rows[j].Cells[HBarCodeTypeCol].Value; grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty; grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; grdSub.Rows[i].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; grdSub.Rows[i].Cells[HSourceEntryIDCol].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; grdSub.Rows[i].Cells[HSourceBillNoCol].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; grdSub.Rows[i].Cells[HSourceBillTypeCol].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value; grdSub.Rows[i].Cells[HPrintCol].Value = "0"; grdSub.Rows[i].Cells[HWeiCol].Value = WeiShu; grdSub.Rows[i].Cells[HDeptID2Col].Value = grdMain.Rows[j].Cells[HDeptIDCol].Value; grdSub.Rows[i].Cells[HDeptNumber2Col].Value = grdMain.Rows[j].Cells[HDeptNumberCol].Value; grdSub.Rows[i].Cells[HDeptName2Col].Value = grdMain.Rows[j].Cells[HDeptNameCol].Value; grdSub.Rows[i].Cells[HRemark2Col].Value = grdMain.Rows[j].Cells[HRemarkCol].Value; k = k + 1; } } else if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0 && ClsPub.isStrNull(grdMain.Rows[j].Cells[HBarCodeTypeCol].Value) == "品种条码") { HNumber = grdMain.Rows[j].Cells[HMaterIDCol].Value.ToString(); //HNumber = HNumber.Replace(".", ""); HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value); HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); for (int i = k; i < HBQty; i++) { if (HSumQty - HMinQty > 0) { WeiShu = ""; HSumQty = HSumQty - HMinQty; } else { //if (HSumQty == HMinQty) //{ WeiShu = ""; //} //else //{ // WeiShu = "尾数"; //} HMinQty = HSumQty; } TM = HNumber; //条码 if (i + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[i].Cells[HTMCol].Value = TM; grdSub.Rows[i].Cells[HBarCodeType2Col].Value = grdMain.Rows[j].Cells[HBarCodeTypeCol].Value; grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; //grdSub.Rows[i].Cells[HModel2Col].Value = grdMain.Rows[j].Cells[HModelCol].Value; grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty; grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; grdSub.Rows[i].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; grdSub.Rows[i].Cells[HSourceEntryIDCol].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; grdSub.Rows[i].Cells[HSourceBillNoCol].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; grdSub.Rows[i].Cells[HSourceBillTypeCol].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; grdSub.Rows[i].Cells[HPrintCol].Value = "0"; grdSub.Rows[i].Cells[HWeiCol].Value = WeiShu; grdSub.Rows[i].Cells[HDeptID2Col].Value = grdMain.Rows[j].Cells[HDeptIDCol].Value; grdSub.Rows[i].Cells[HDeptNumber2Col].Value = grdMain.Rows[j].Cells[HDeptNumberCol].Value; grdSub.Rows[i].Cells[HDeptName2Col].Value = grdMain.Rows[j].Cells[HDeptNameCol].Value; grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value; grdSub.Rows[i].Cells[HRemark2Col].Value = grdMain.Rows[j].Cells[HRemarkCol].Value; k = k + 1; } } else if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0 && ClsPub.isStrNull(grdMain.Rows[j].Cells[HBarCodeTypeCol].Value) == "唯一条码") { HNumber = grdMain.Rows[j].Cells[HMaterIDCol].Value.ToString(); //HNumber = HNumber.Replace(".", ""); HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value); HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); n = 0; for (int i = k; i < HBQty; i++) { if (HSumQty - HMinQty > 0) { WeiShu = ""; HSumQty = HSumQty - HMinQty; } else { if (HSumQty == HMinQty) { WeiShu = ""; } else { WeiShu = "尾数"; } HMinQty = HSumQty; } // LSH = LSH + 1; LSH2 = LSH.ToString(); while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0 { LSH2 = "0" + LSH2; } sDate = ClsPub.GetServerDate(0); sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2); sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString(); sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2); sDay = "0" + ClsPub.isDate(sDate).Day.ToString(); sDay = sDay.Substring(sDay.Length - 2, 2); //================================== TM = HNumber + sYear + sPeriod + sDay + LSH2; //条码 if (i + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[i].Cells[HTMCol].Value = TM; grdSub.Rows[i].Cells[HBarCodeType2Col].Value = grdMain.Rows[j].Cells[HBarCodeTypeCol].Value; grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; //grdSub.Rows[i].Cells[HModel2Col].Value = grdMain.Rows[j].Cells[HModelCol].Value; grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty; grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; grdSub.Rows[i].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; grdSub.Rows[i].Cells[HSourceEntryIDCol].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; grdSub.Rows[i].Cells[HSourceBillNoCol].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; grdSub.Rows[i].Cells[HSourceBillTypeCol].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; grdSub.Rows[i].Cells[HPrintCol].Value = "0"; grdSub.Rows[i].Cells[HWeiCol].Value = WeiShu; grdSub.Rows[i].Cells[HBarcodeNoCol].Value = n + 1; grdSub.Rows[i].Cells[HBarcodeQtysCol].Value = grdMain.Rows[j].Cells[HBQtyCol].Value; grdSub.Rows[i].Cells[HDeptID2Col].Value = grdMain.Rows[j].Cells[HDeptIDCol].Value; grdSub.Rows[i].Cells[HDeptNumber2Col].Value = grdMain.Rows[j].Cells[HDeptNumberCol].Value; grdSub.Rows[i].Cells[HDeptName2Col].Value = grdMain.Rows[j].Cells[HDeptNameCol].Value; grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value; grdSub.Rows[i].Cells[HRemark2Col].Value = grdMain.Rows[j].Cells[HRemarkCol].Value; k = k + 1; n = n + 1; } } } string HWei = ""; //尾数 string HBarCode = ""; string HBarCodeType = ""; Int64 HMaterID = 0; Int64 HUnitID = 0; double HQty2 = 0; string HBatchNo = ""; Int64 HSupID = 0; Int64 HGroupID = 0; int HPrintQty = 0; Int64 HSourceInterID = 0; Int64 HSourceEntryID = 0; string HSourceBillNo = ""; string HSourceBillType = ""; Int64 HBarcodeNo = 0; //托号 Int64 HBarcodeQtys = 0; //总托数 Int64 HDeptID = 0; string HRemark = ""; try { oCn.BeginTran(); for (int i = 0; i < grdSub.Rows.Count; i++) { if (ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value) != 0) { HWei = ClsPub.isStrNull(grdSub.Rows[i].Cells[HWeiCol].Value); HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HTMCol].Value); HBarCodeType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBarCodeType2Col].Value); HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value); HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value); HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value); HBatchNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBatchNo2Col].Value); HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterIDCol].Value); HSourceEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceEntryIDCol].Value); HSourceBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillNoCol].Value); HSourceBillType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillTypeCol].Value); HDeptID = ClsPub.isLong(grdSub.Rows[i].Cells[HDeptID2Col].Value); HRemark = ClsPub.isStrNull(grdSub.Rows[i].Cells[HRemark2Col].Value); HBarcodeQtys = ClsPub.isLong(grdSub.Rows[i].Cells[HBarcodeQtysCol].Value); HBarcodeNo = ClsPub.isLong(grdSub.Rows[i].Cells[HBarcodeNoCol].Value); oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " + ",HBarcodeQtys,HBarcodeNo,HDeptID,HRemark " + ") values (" + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HBatchNo + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'" + "," + HBarcodeQtys + "," + HBarcodeNo + "," + HDeptID + ",'" + HRemark + "')"); oCn.RunProc("exec setLSH '" + ClsPub.GetServerDate(0) + "'"); } } oCn.Commit(); MessageBox.Show("条码生成完毕!"); tabControl1.SelectedIndex = 1; } catch (Exception e) { oCn.RollBack(); MessageBox.Show("条码生成失败!" + e.Message); } } //生成条码(批次) private void SaveBarCodeByBatchNo() { grdSub.Rows.Clear(); int LSHlen = 6; //流水号长度 int SumLen = 10; //总长度 string TM = ""; //条码 string HNumber = ""; //物料代码 double HSumQty = 0; //产品数量 double HQty = 0; //数量 int HBQty = 0; //箱数量 double HMinQty = 0; //每箱数量 string WeiShu = ""; //尾数 int LSH = 0; //流水号 string LSH2 = ""; //流水号转换成字符 string sDate = ""; //日期 string sYear = ""; //年 string sPeriod = ""; //月 string sDay = ""; //日 int k = 0; DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); Ds = oCn.RunProcReturn("exec GetLSH '" + ClsPub.GetServerDate(0) + "'", "GetLSH"); LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]); for (int j = 0; j < grdMain.Rows.Count; j++) { if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0) { //生成流水号 HNumber = grdMain.Rows[j].Cells[HMaterIDCol].Value.ToString(); LSH = LSH + 1; LSH2 = LSH.ToString(); while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0 { LSH2 = "0" + LSH2; } sDate = ClsPub.GetServerDate(0); sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2); sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString(); sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2); sDay = "0" + ClsPub.isDate(sDate).Day.ToString(); sDay = sDay.Substring(sDay.Length - 2, 2); //================================== TM = HNumber + sYear + sPeriod + sDay + LSH2; //条码 HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value); HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); for (int i = k; i < HBQty; i++) { if (HSumQty - HMinQty > 0) { WeiShu = ""; HSumQty = HSumQty - HMinQty; } else { //if (HSumQty == HMinQty) //{ WeiShu = ""; //} //else //{ // WeiShu = "尾数"; //} HMinQty = HSumQty; } if (i + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[i].Cells[HTMCol].Value = TM; grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty; grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; grdSub.Rows[i].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; grdSub.Rows[i].Cells[HSourceEntryIDCol].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; grdSub.Rows[i].Cells[HSourceBillNoCol].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; grdSub.Rows[i].Cells[HSourceBillTypeCol].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value; grdSub.Rows[i].Cells[HPrintCol].Value = "0"; grdSub.Rows[i].Cells[HWeiCol].Value = WeiShu; grdSub.Rows[i].Cells[HDeptID2Col].Value = grdMain.Rows[j].Cells[HDeptIDCol].Value; grdSub.Rows[i].Cells[HDeptNumber2Col].Value = grdMain.Rows[j].Cells[HDeptNumberCol].Value; grdSub.Rows[i].Cells[HDeptName2Col].Value = grdMain.Rows[j].Cells[HDeptNameCol].Value; grdSub.Rows[i].Cells[HRemark2Col].Value = grdMain.Rows[j].Cells[HRemarkCol].Value; k = k + 1; } } } string HWei = ""; //尾数 string HBarCode = ""; string HBarCodeType = ""; Int64 HMaterID = 0; Int64 HUnitID = 0; double HQty2 = 0; string HBatchNo = ""; Int64 HSupID = 0; Int64 HGroupID = 0; int HPrintQty = 0; Int64 HSourceInterID = 0; Int64 HSourceEntryID = 0; string HSourceBillNo = ""; string HSourceBillType = ""; Int64 HDeptID = 0; string HRemark = ""; try { oCn.BeginTran(); for (int i = 0; i < grdSub.Rows.Count; i++) { if (ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value) != 0) { HBarCode = grdSub.Rows[i].Cells[HTMCol].Value.ToString(); HBarCodeType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBarCodeType2Col].Value); HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value); HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value); HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value); HBatchNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBatchNo2Col].Value); HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterIDCol].Value); HSourceEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceEntryIDCol].Value); HSourceBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillNoCol].Value); HSourceBillType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillTypeCol].Value); HDeptID = ClsPub.isLong(grdSub.Rows[i].Cells[HDeptID2Col].Value); HRemark = ClsPub.isStrNull(grdSub.Rows[i].Cells[HRemark2Col].Value); oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " + ",HDeptID,HRemark " + ") values (" + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HBatchNo + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'" + "," + HDeptID + ",'" + HRemark + "')"); } } oCn.RunProc("exec setLSH '" + ClsPub.GetServerDate(0) + "'"); oCn.Commit(); MessageBox.Show("条码生成完毕!"); tabControl1.SelectedIndex = 1; } catch (Exception e) { oCn.RollBack(); MessageBox.Show("条码生成失败!" + e.Message); } } //生成条码(单品) private void SaveBarCodeBySingle() { lblCaption.Focus(); grdSub.Rows.Clear(); int LSHlen = 6; //流水号长度 int SumLen = 10; //总长度 string TM = ""; //条码 string HNumber = ""; //物料代码 double HSumQty = 0; //产品数量 double HMinQty = 0; //最小包装数 int HBQty = 0; //箱数 double HQty = 0; //数量 string WeiShu = ""; //尾数 int LSH = 0; //流水号 string LSH2 = ""; //流水号转换成字符 string sDate = ""; //日期 string sYear = ""; //年 string sPeriod = ""; //月 string sDay = ""; //日 int k = 0; int n = 0; DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); Ds = oCn.RunProcReturn("exec GetLSH '" + ClsPub.GetServerDate(0) + "'", "GetLSH"); LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]); for (int j = 0; j < grdMain.Rows.Count; j++) { if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0) { HNumber = grdMain.Rows[j].Cells[HMaterIDCol].Value.ToString(); //HNumber = HNumber.Replace(".", ""); HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value); HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); n = 0; for (int i = k; i < HBQty; i++) { if (HSumQty - HMinQty > 0) { WeiShu = ""; HSumQty = HSumQty - HMinQty; } else { if (HSumQty == HMinQty) { WeiShu = ""; } else { WeiShu = "尾数"; } HMinQty = HSumQty; } // LSH = LSH + 1; LSH2 = LSH.ToString(); while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0 { LSH2 = "0" + LSH2; } sDate = ClsPub.GetServerDate(0); sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2); sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString(); sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2); sDay = "0" + ClsPub.isDate(sDate).Day.ToString(); sDay = sDay.Substring(sDay.Length - 2, 2); //================================== TM = HNumber + sYear + sPeriod + sDay + LSH2; //条码 if (i + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[i].Cells[HTMCol].Value = TM; grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; grdSub.Rows[i].Cells[HPinfan2Col].Value = grdMain.Rows[j].Cells[HPinfanCol].Value; grdSub.Rows[i].Cells[HPinfanBarCode2Col].Value = grdMain.Rows[j].Cells[HPinfanBarCodeCol].Value; grdSub.Rows[i].Cells[HAuxPropID2Col].Value = grdMain.Rows[j].Cells[HAuxPropIDCol].Value; grdSub.Rows[i].Cells[HAuxPropNumber2Col].Value = grdMain.Rows[j].Cells[HAuxPropNumberCol].Value; grdSub.Rows[i].Cells[HAuxPropName2Col].Value = grdMain.Rows[j].Cells[HAuxPropNameCol].Value; grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty; //if (grdMain.Columns[HBillNoCol].ReadOnly == false) //{ // grdSub.Rows[i].Cells[HBatchNo2Col].Value = ClsPub.isDate(sDate).Year.ToString() + sPeriod + getWeekNumInMonth(ClsPub.isDate(sDate)); //} //else //{ //grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; //} grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; grdSub.Rows[i].Cells[HSourceInterID2Col].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; grdSub.Rows[i].Cells[HSourceEntryID2Col].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; grdSub.Rows[i].Cells[HSourceBillNo2Col].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; grdSub.Rows[i].Cells[HSourceBillType2Col].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; grdSub.Rows[i].Cells[HPrintCol].Value = "0"; grdSub.Rows[i].Cells[HWeiCol].Value = WeiShu; grdSub.Rows[i].Cells[HBarcodeNoCol].Value = n + 1; grdSub.Rows[i].Cells[HBarcodeQtysCol].Value = grdMain.Rows[j].Cells[HBQtyCol].Value; grdSub.Rows[i].Cells[HSupID2Col].Value = grdMain.Rows[j].Cells[HSupIDCol].Value; grdSub.Rows[i].Cells[HSupNumber2Col].Value = grdMain.Rows[j].Cells[HSupNumberCol].Value; grdSub.Rows[i].Cells[HSupName2Col].Value = grdMain.Rows[j].Cells[HSupNameCol].Value; grdSub.Rows[i].Cells[HDeptID2Col].Value = grdMain.Rows[j].Cells[HDeptIDCol].Value; grdSub.Rows[i].Cells[HDeptNumber2Col].Value = grdMain.Rows[j].Cells[HDeptNumberCol].Value; grdSub.Rows[i].Cells[HDeptName2Col].Value = grdMain.Rows[j].Cells[HDeptNameCol].Value; grdSub.Rows[i].Cells[HRemark2Col].Value = grdMain.Rows[j].Cells[HRemarkCol].Value; grdSub.Rows[i].Cells[HDate2Col].Value = grdMain.Rows[j].Cells[HDateCol].Value; grdSub.Rows[i].Cells[HWhID2Col].Value = grdMain.Rows[j].Cells[HWhIDCol].Value; grdSub.Rows[i].Cells[HWhNumber2Col].Value = grdMain.Rows[j].Cells[HWhNumberCol].Value; grdSub.Rows[i].Cells[HWhName2Col].Value = grdMain.Rows[j].Cells[HWhNameCol].Value; grdSub.Rows[i].Cells[HSPID2Col].Value = grdMain.Rows[j].Cells[HSPIDCol].Value; grdSub.Rows[i].Cells[HSPNumber2Col].Value = grdMain.Rows[j].Cells[HSPNumberCol].Value; grdSub.Rows[i].Cells[HSPName2Col].Value = grdMain.Rows[j].Cells[HSPNameCol].Value; k = k + 1; n = n + 1; } } } string HWei = ""; //尾数 string HBarCode = ""; string HBarCodeType = ""; Int64 HMaterID = 0; Int64 HAuxPropID = 0; Int64 HUnitID = 0; double HQty2 = 0; string HBatchNo = ""; Int64 HSupID = 0; Int64 HGroupID = 0; int HPrintQty = 0; Int64 HSourceInterID = 0; Int64 HSourceEntryID = 0; string HSourceBillNo = ""; string HSourceBillType = ""; Int64 HBarcodeNo = 0; //托号 Int64 HBarcodeQtys = 0; //总托数 Int64 HDeptID = 0; Int64 HWhID = 0; Int64 HSPID = 0; string HRemark = ""; string HMaterName = ""; string HMaterModel = ""; string HPinfan = ""; try { oCn.BeginTran(); for (int i = 0; i < grdSub.Rows.Count; i++) { if (ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value) != 0) { HWei = ClsPub.isStrNull(grdSub.Rows[i].Cells[HWeiCol].Value); HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HTMCol].Value); HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text); HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value); HAuxPropID = ClsPub.isLong(grdSub.Rows[i].Cells[HAuxPropID2Col].Value); HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value); HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value); HBatchNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBatchNo2Col].Value); HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterID2Col].Value); HSourceEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceEntryID2Col].Value); HSourceBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillNo2Col].Value); HSourceBillType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillType2Col].Value); HBarcodeQtys = ClsPub.isLong(grdSub.Rows[i].Cells[HBarcodeQtysCol].Value); HBarcodeNo = ClsPub.isLong(grdSub.Rows[i].Cells[HBarcodeNoCol].Value); HSupID = ClsPub.isLong(grdSub.Rows[i].Cells[HSupID2Col].Value); HDeptID = ClsPub.isLong(grdSub.Rows[i].Cells[HDeptID2Col].Value); HWhID = ClsPub.isLong(grdSub.Rows[i].Cells[HWhID2Col].Value); HSPID = ClsPub.isLong(grdSub.Rows[i].Cells[HSPID2Col].Value); HRemark = ClsPub.isStrNull(grdSub.Rows[i].Cells[HRemark2Col].Value); HMaterName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterName2Col].Value); HMaterModel = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value); HPinfan = ClsPub.isStrNull(grdSub.Rows[i].Cells[HPinfan2Col].Value); oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " + ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " + ",HMaterName,HMaterModel,HPinfan,HAuxPropID " + ") values (" + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString() + ",'" + HBatchNo + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'" + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'" + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ")"); oCn.RunProc("exec setLSH '" + ClsPub.GetServerDate(0) + "'"); } } oCn.Commit(); MessageBox.Show("条码生成完毕!"); tabControl1.SelectedIndex = 1; } catch (Exception e) { oCn.RollBack(); MessageBox.Show("条码生成失败!" + e.Message); } } //生成条码(品种) private void SaveBarCodeByVariety() { lblCaption.Focus(); grdSub.Rows.Clear(); string TM = ""; //条码 string HNumber = ""; //物料代码 double HSumQty = 0; //产品数量 double HMinQty = 0; //最小包装数 int HBQty = 0; //箱数 double HQty = 0; //数量 string WeiShu = ""; //尾数 int k = 0; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); for (int j = 0; j < grdMain.Rows.Count; j++) { if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0) { HNumber = grdMain.Rows[j].Cells[HMaterIDCol].Value.ToString(); //HNumber = HNumber.Replace(".", ""); HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value); HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); for (int i = k; i < HBQty; i++) { if (HSumQty - HMinQty > 0) { WeiShu = ""; HSumQty = HSumQty - HMinQty; } else { //if (HSumQty == HMinQty) //{ WeiShu = ""; //} //else //{ // WeiShu = "尾数"; //} HMinQty = HSumQty; } TM = HNumber; //条码 if (i + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[i].Cells[HTMCol].Value = TM; grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; //grdSub.Rows[i].Cells[HModel2Col].Value = grdMain.Rows[j].Cells[HModelCol].Value; grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty; grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; grdSub.Rows[i].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; grdSub.Rows[i].Cells[HSourceEntryIDCol].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; grdSub.Rows[i].Cells[HSourceBillNoCol].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; grdSub.Rows[i].Cells[HSourceBillTypeCol].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; grdSub.Rows[i].Cells[HPrintCol].Value = "0"; grdSub.Rows[i].Cells[HWeiCol].Value = WeiShu; grdSub.Rows[i].Cells[HDeptID2Col].Value = grdMain.Rows[j].Cells[HDeptIDCol].Value; grdSub.Rows[i].Cells[HDeptNumber2Col].Value = grdMain.Rows[j].Cells[HDeptNumberCol].Value; grdSub.Rows[i].Cells[HDeptName2Col].Value = grdMain.Rows[j].Cells[HDeptNameCol].Value; grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value; grdSub.Rows[i].Cells[HRemark2Col].Value = grdMain.Rows[j].Cells[HRemarkCol].Value; k = k + 1; } } } string HWei = ""; //尾数 string HBarCode = ""; string HBarCodeType = ""; Int64 HMaterID = 0; Int64 HUnitID = 0; double HQty2 = 0; string HBatchNo = ""; Int64 HSupID = 0; Int64 HGroupID = 0; Int64 HDeptID = 0; int HPrintQty = 0; Int64 HSourceInterID = 0; Int64 HSourceEntryID = 0; string HSourceBillNo = ""; string HSourceBillType = ""; string HRemark = ""; try { oCn.BeginTran(); for (int i = 0; i < grdSub.Rows.Count; i++) { if (ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value) != 0) { HWei = ClsPub.isStrNull(grdSub.Rows[i].Cells[HWeiCol].Value); HDeptID = ClsPub.isLong(txtHDeptID.Tag); HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HTMCol].Value); HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text); HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value); HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value); HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value); HBatchNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBatchNo2Col].Value); HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterIDCol].Value); HSourceEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceEntryIDCol].Value); HSourceBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillNoCol].Value); HSourceBillType = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceBillTypeCol].Value); oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + ",HBatchNo,HSupID,HGroupID,HDeptID,HMaker,HMakeDate,HPrintQty" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " + ",HRemark " + ") values (" + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HBatchNo + "'," + HSupID + "," + HGroupID + "," + HDeptID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty + ", " + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'" + ",'" + HRemark + "')"); } } oCn.Commit(); MessageBox.Show("条码生成完毕!"); tabControl1.SelectedIndex = 1; } catch (Exception e) { oCn.RollBack(); MessageBox.Show("条码生成失败!" + e.Message); } } #endregion #region 窗体处理方法 //初始化GRID private void initGrid() { // grdMain.ColumnCount = 48; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name); grdMain.Columns[HMainIDCol].HeaderText = "源单主ID"; grdMain.Columns[HSubIDCol].HeaderText = "源单子ID"; grdMain.Columns[HBillNoCol].HeaderText = "源单单号"; grdMain.Columns[HBillTypeCol].HeaderText = "单据类型"; grdMain.Columns[HMaterIDCol].HeaderText = "物料ID"; grdMain.Columns[HMaterNumberCol].HeaderText = "物料代码"; grdMain.Columns[HMaterNameCol].HeaderText = "物料名称"; grdMain.Columns[HMaterModelCol].HeaderText = "规格型号"; grdMain.Columns[HModelCol].HeaderText = "自定义规格"; grdMain.Columns[HPinfanCol].HeaderText = "品番"; grdMain.Columns[HPinfanBarCodeCol].HeaderText = "HPinfanBarCode"; grdMain.Columns[HAuxPropIDCol].HeaderText = "辅助属性ID"; grdMain.Columns[HAuxPropNumberCol].HeaderText = "辅助属性代码"; grdMain.Columns[HAuxPropNameCol].HeaderText = "辅助属性名称"; grdMain.Columns[HUnitIDCol].HeaderText = "计量单位ID"; grdMain.Columns[HUnitNumberCol].HeaderText = "计量单位代码"; grdMain.Columns[HUnitNameCol].HeaderText = "计量单位名称"; grdMain.Columns[HBarCodeTypeCol].HeaderText = "条码类型"; grdMain.Columns[HBatchManagerCol].HeaderText = "是否启用批次"; grdMain.Columns[HBatchNoCol].HeaderText = "批号"; grdMain.Columns[HQtyCol].HeaderText = "数量"; grdMain.Columns[HMinQtyCol].HeaderText = "最小包装数"; grdMain.Columns[HBQtyCol].HeaderText = "箱数"; grdMain.Columns[HSupIDCol].HeaderText = "供应商ID"; grdMain.Columns[HSupNumberCol].HeaderText = "供应商代码"; grdMain.Columns[HSupNameCol].HeaderText = "供应商"; grdMain.Columns[HDeptIDCol].HeaderText = "车间ID"; grdMain.Columns[HDeptNumberCol].HeaderText = "车间代码"; grdMain.Columns[HDeptNameCol].HeaderText = "车间"; grdMain.Columns[HWhIDCol].HeaderText = "仓库ID"; grdMain.Columns[HWhNumberCol].HeaderText = "仓库代码"; grdMain.Columns[HWhNameCol].HeaderText = "仓库"; grdMain.Columns[HSPIDCol].HeaderText = "仓位ID"; grdMain.Columns[HSPNumberCol].HeaderText = "仓位代码"; grdMain.Columns[HSPNameCol].HeaderText = "仓位"; grdMain.Columns[HInstructNoCol].HeaderText = "指令单号"; grdMain.Columns[HSeOrderBillNoCol].HeaderText = "销售订单号"; grdMain.Columns[HDateCol].HeaderText = "进料日期"; grdMain.Columns[HRemarkCol].HeaderText = "备注"; //// grdMain.Columns[HSnoCol].HeaderText = "序号"; //格式化 grdMain.Columns[HTagCol].Visible = false; //隐藏列 grdMain.Columns[HMainIDCol].Visible = false; grdMain.Columns[HSubIDCol].Visible = false; grdMain.Columns[HBillTypeCol].Visible = false; grdMain.Columns[HMaterIDCol].Visible = false; grdMain.Columns[HModelCol].Visible = false; grdMain.Columns[HBatchNoCol].Visible = false; grdMain.Columns[HAuxPropIDCol].Visible = false; grdMain.Columns[HUnitIDCol].Visible = false; grdMain.Columns[HinitQtyCol].Visible = false; grdMain.Columns[HSupIDCol].Visible = false; grdMain.Columns[HSupNumberCol].Visible = false; grdMain.Columns[HSupNameCol].Visible = false; grdMain.Columns[HDeptIDCol].Visible = false; grdMain.Columns[HDeptNumberCol].Visible = false; grdMain.Columns[HDeptNameCol].Visible = false; grdMain.Columns[HWhIDCol].Visible = false; grdMain.Columns[HWhNumberCol].Visible = false; grdMain.Columns[HWhNameCol].Visible = false; grdMain.Columns[HSPIDCol].Visible = false; grdMain.Columns[HSPNumberCol].Visible = false; grdMain.Columns[HSPNameCol].Visible = false; grdMain.Columns[HSourceInterIDCol].Visible = false; grdMain.Columns[HSourceEntryIDCol].Visible = false; grdMain.Columns[HSourceBillNoCol].Visible = false; grdMain.Columns[HSourceBillTypeCol].Visible = false; grdMain.Columns[HInstructIDCol].Visible = false; grdMain.Columns[HInstructNoCol].Visible = false; grdMain.Columns[HSeOrderBillIDCol].Visible = false; grdMain.Columns[HSeOrderBillNoCol].Visible = false; grdMain.Columns[HBarCodeTypeCol].Visible = false; grdMain.Columns[HBatchManagerCol].Visible = false; grdMain.Columns[HDateCol].Visible = false; grdMain.Columns[HPinfanBarCodeCol].Visible = false; //设置可编辑列 string sAllowCol = HQtyCol.ToString()+ "," + HMinQtyCol.ToString() + "," + HMaterNumberCol.ToString() + "," + HMaterNameCol.ToString() + "," + HMaterModelCol.ToString() + "," + HPinfanCol.ToString() + "," + HAuxPropNumberCol.ToString() + "," + HUnitNumberCol.ToString() + "," + HRemarkCol.ToString(); //设置合计列 string sTotalCol = HQtyCol.ToString(); // DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol,oSumGrid); //---------------------------- grdSub.ColumnCount = 45; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name); grdSub.Columns[HSelectCol].HeaderText = "选择"; grdSub.Columns[HTMCol].HeaderText = "条码编号"; grdSub.Columns[HBarCodeType2Col].HeaderText = "条码类型"; grdSub.Columns[HSno2Col].HeaderText = "序号"; grdSub.Columns[HMaterID2Col].HeaderText = "物料ID"; grdSub.Columns[HMaterNumber2Col].HeaderText = "物料代码"; grdSub.Columns[HMaterName2Col].HeaderText = "物料名称"; grdSub.Columns[HMaterModel2Col].HeaderText = "规格型号"; grdSub.Columns[HModel2Col].HeaderText = "自定义规格"; grdSub.Columns[HAuxPropID2Col].HeaderText = "辅助属性ID"; grdSub.Columns[HAuxPropNumber2Col].HeaderText = "辅助属性代码"; grdSub.Columns[HAuxPropName2Col].HeaderText = "辅助属性名称"; grdSub.Columns[HPinfan2Col].HeaderText = "品番"; grdSub.Columns[HPinfanBarCode2Col].HeaderText = "HPinfanBarCode"; grdSub.Columns[HBatchNo2Col].HeaderText = "批号"; grdSub.Columns[HUnitID2Col].HeaderText = "计量单位ID"; grdSub.Columns[HUnitNumber2Col].HeaderText = "计量单位代码"; grdSub.Columns[HUnitName2Col].HeaderText = "计量单位名称"; grdSub.Columns[HQty2Col].HeaderText = "数量"; grdSub.Columns[HWeiCol].HeaderText = "尾数"; grdSub.Columns[HPrintCol].HeaderText = "打印次数"; grdSub.Columns[HSourceInterID2Col].HeaderText = "源单主ID"; grdSub.Columns[HSourceEntryID2Col].HeaderText = "源单子ID"; grdSub.Columns[HSourceBillNo2Col].HeaderText = "源单单号"; grdSub.Columns[HSourceBillType2Col].HeaderText = "源单类型"; grdSub.Columns[HSeOrderBillNo2Col].HeaderText = "销售订单号"; grdSub.Columns[HBarcodeNoCol].HeaderText = "托号"; grdSub.Columns[HBarcodeQtysCol].HeaderText = "总托数"; grdSub.Columns[HSupID2Col].HeaderText = "供应商ID"; grdSub.Columns[HSupNumber2Col].HeaderText = "供应商代码"; grdSub.Columns[HSupName2Col].HeaderText = "供应商"; grdSub.Columns[HDeptID2Col].HeaderText = "车间ID"; grdSub.Columns[HDeptNumber2Col].HeaderText = "车间代码"; grdSub.Columns[HDeptName2Col].HeaderText = "车间"; grdSub.Columns[HWhID2Col].HeaderText = "仓库ID"; grdSub.Columns[HWhNumber2Col].HeaderText = "仓库代码"; grdSub.Columns[HWhName2Col].HeaderText = "仓库"; grdSub.Columns[HSPID2Col].HeaderText = "仓位ID"; grdSub.Columns[HSPNumber2Col].HeaderText = "仓位代码"; grdSub.Columns[HSPName2Col].HeaderText = "仓位"; grdSub.Columns[HInstructNo2Col].HeaderText = "指令单号"; grdSub.Columns[HDate2Col].HeaderText = "进料日期"; grdSub.Columns[HRemark2Col].HeaderText = "备注"; //格式化 grdSub.Columns[HMaterID2Col].Visible = false; grdSub.Columns[HModel2Col].Visible = false; grdSub.Columns[HAuxPropID2Col].Visible = false; grdSub.Columns[HUnitID2Col].Visible = false; grdSub.Columns[HPrintCol].Visible = false; grdSub.Columns[HSourceInterID2Col].Visible = false; grdSub.Columns[HSourceEntryID2Col].Visible = false; grdSub.Columns[HSourceBillType2Col].Visible = false; grdSub.Columns[HDeptID2Col].Visible = false; grdSub.Columns[HDeptNumber2Col].Visible = false; grdSub.Columns[HDeptName2Col].Visible = false; grdSub.Columns[HDate2Col].Visible = false; grdSub.Columns[HBarCodeType2Col].Visible = false; grdSub.Columns[HBatchNo2Col].Visible = false; grdSub.Columns[HWeiCol].Visible = false; grdSub.Columns[HBarcodeNoCol].Visible = false; grdSub.Columns[HBarcodeQtysCol].Visible = false; grdSub.Columns[HSupID2Col].Visible = false; grdSub.Columns[HSupNumber2Col].Visible = false; grdSub.Columns[HSupName2Col].Visible = false; grdSub.Columns[HWhID2Col].Visible = false; grdSub.Columns[HWhNumber2Col].Visible = false; grdSub.Columns[HWhName2Col].Visible = false; grdSub.Columns[HSPID2Col].Visible = false; grdSub.Columns[HSPNumber2Col].Visible = false; grdSub.Columns[HSPName2Col].Visible = false; grdSub.Columns[HInstructID2Col].Visible = false; grdSub.Columns[HInstructNo2Col].Visible = false; grdSub.Columns[HSeOrderBillID2Col].Visible = false; grdSub.Columns[HSeOrderBillNo2Col].Visible = false; grdSub.Columns[HPinfanBarCode2Col].Visible = false; DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); grdSub.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //选行模式 } //公式重算 private void RowCount(int sRow, int sTag) { if (sTag == 0) { //箱数列=数量/最小包装数 double sMoney = 0; if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value) == 0) { sMoney = 0; } else { sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value); } sMoney = Math.Ceiling(sMoney); grdMain.Rows[sRow].Cells[HBQtyCol].Value = sMoney; } else { } if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) > ClsPub.isDoule(grdMain.Rows[sRow].Cells[HinitQtyCol].Value) && ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HBillNoCol].Value) != "") { MessageBox.Show("所输入的产品总数量大于剩余可生成数量" + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HinitQtyCol].Value) + ",请重新输入!"); grdMain.Rows[sRow].Cells[HQtyCol].Value = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HinitQtyCol].Value); return; } } //核对选择的内容 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 == HMaterNumberCol) //物料代码列 { //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 == HUnitIDCol) //单位ID列 { //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, HMaterIDCol,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) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet oDs = new DataSet(); DataSet oDs2 = new DataSet(); long sHMaterID = 0; long sHAuxPropID = 0; DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View(); DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View(); DAL.ClsK3_Property_View oProperty = new DAL.ClsK3_Property_View();//K3辅助属性 if (!grdStatus) { return; } //if (oSumGrid.FindAllowEditCol(sCol)) //{ oSumGrid.EditStatus = true; //} //else //{ // return; //} switch (sKeyCode) { case 118: //F7 { switch (sCol) { case HMaterNumberCol: oMater.WherePart = ""; if (oMater.RefreshViewForBig("")) { if (oMater.GetInfoByID(oMater.oModel.HItemID)) { grdMain.Rows[sRow].Cells[HMaterIDCol].Value = oMater.omodel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber; grdMain.Rows[sRow].Cells[HMaterNameCol].Value = oMater.omodel.HName; grdMain.Rows[sRow].Cells[HMaterModelCol].Value = oMater.omodel.HModel; if (oUnit.GetInfoByID(oMater.omodel.HUnitID)) { grdMain.Rows[sRow].Cells[HUnitIDCol].Value = oUnit.omodel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = oUnit.omodel.HNumber; grdMain.Rows[sRow].Cells[HUnitNameCol].Value = oUnit.omodel.HName; } else { grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0; grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HUnitNameCol].Value = ""; } oEdit.Text = oMater.omodel.HNumber; } else { grdMain.Rows[sRow].Cells[HMaterIDCol].Value = 0; grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HMaterNameCol].Value = ""; grdMain.Rows[sRow].Cells[HMaterModelCol].Value = ""; grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0; grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HUnitNameCol].Value = ""; } } else { grdMain.Rows[sRow].Cells[HMaterIDCol].Value = 0; grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HMaterNameCol].Value = ""; grdMain.Rows[sRow].Cells[HMaterModelCol].Value = ""; grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0; } //grdMain.Rows[sRow].Cells[HDateCol].Value = ClsPub.GetServerDate(0); sHMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[sRow].Cells[HMaterIDCol].Value); sHAuxPropID = DBUtility.ClsPub.isLong(grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value); //获取品番 oDs2 = oCn.RunProcReturn("exec h_p_HMaterPinfan " + sHMaterID, "h_p_HMaterPinfan"); // if (oDs2 != null && oDs2.Tables[0].Rows.Count > 0) { grdMain.Rows[sRow].Cells[HPinfanCol].Value = DBUtility.ClsPub.isStrNull(oDs2.Tables[0].Rows[0]["HPinfan"]); grdMain.Rows[sRow].Cells[HPinfanBarCodeCol].Value = DBUtility.ClsPub.isStrNull(oDs2.Tables[0].Rows[0]["HPinfanBarCode"]); } //获取最新最小包装数 oDs = oCn.RunProcReturn("exec h_p_Gy_StdPack " + sHMaterID + "," + sHAuxPropID, "h_p_Gy_StdPack"); // if (oDs != null && oDs.Tables[0].Rows.Count > 0) { grdMain.Rows[sRow].Cells[HMinQtyCol].Value = DBUtility.ClsPub.isSingle(oDs.Tables[0].Rows[0]["HMinPack"]); } break; case HAuxPropNumberCol: oProperty.WherePart = ""; if (oProperty.RefreshView(" and HMaterID= " + DBUtility.ClsPub.isLong(grdMain.Rows[sRow].Cells[HMaterIDCol].Value).ToString() + " ")) { grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = oProperty.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = oProperty.oModel.HNumber; grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = oProperty.oModel.HName; //获取最新最小包装数 sHMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[sRow].Cells[HMaterIDCol].Value); sHAuxPropID = DBUtility.ClsPub.isLong(grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value); oDs = oCn.RunProcReturn("exec h_p_Gy_StdPack " + sHMaterID + "," + sHAuxPropID, "h_p_Gy_StdPack"); // if (oDs != null && oDs.Tables[0].Rows.Count > 0) { grdMain.Rows[sRow].Cells[HMinQtyCol].Value = DBUtility.ClsPub.isSingle(oDs.Tables[0].Rows[0]["HMinPack"]); } EditingControl.Text = oProperty.oModel.HNumber; } else { grdMain.Rows[sRow].Cells[HAuxPropIDCol].Value = 0; grdMain.Rows[sRow].Cells[HAuxPropNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HAuxPropNameCol].Value = ""; } break; case HUnitNumberCol: oUnit.WherePart = ""; if (oUnit.RefreshView()) { grdMain.Rows[sRow].Cells[HUnitIDCol].Value = oUnit.oModel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = oUnit.oModel.HNumber; grdMain.Rows[sRow].Cells[HUnitNameCol].Value = oUnit.oModel.HName; EditingControl.Text = oUnit.oModel.HNumber; } else { grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0; grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HUnitNameCol].Value = ""; } break; case HDeptNumberCol: BLL.ClsBaseSelect_K3.SetGridByDept_K3(grdMain, sRow, HDeptIDCol, HDeptNumberCol, HDeptNameCol); oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HDeptNumberCol].Value); break; case HDateCol: BLL.ClsPub_BLL.Sub_SelectDate(grdMain, sRow, HDateCol); oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HDateCol].Value); break; default: break; } bc.Enabled = true; 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 = ""; DAL.Cls_S_K3_PoinStockList oK3_PoinStockList = new DAL.Cls_S_K3_PoinStockList(); if (oK3_PoinStockList.Refresh(sWhere)) //选择原单 { FillSelectData(oK3_PoinStockList.oBillSelectColl); } } else if (cmbSourceBillType.Text.Trim() == "倒箱单") //幻 { string sWhere = ""; DAL.Cls_S_KF_ChangeBoxBillList oCls_S_KF_ChangeBoxBillList = new DAL.Cls_S_KF_ChangeBoxBillList(); if (oCls_S_KF_ChangeBoxBillList.Refresh(sWhere)) //选择原单 { FillSelectData(oCls_S_KF_ChangeBoxBillList.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 == "72") { grdMain.Rows.Add(); grdMain.Rows[i].Cells[HTagCol].Value = "*"; //得到信息 Ds = oCn.RunProcReturn("select * from h_v_K3_PoinStockList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_K3_PoinStockList"); //写入信息 Sub_WriteInForm(Ds.Tables[0], i); } //即时库存 if (oSelectRow.BillType == "JSKC") { grdMain.Rows.Add(); Application.DoEvents(); //得到信息 Ds = oCn.RunProcReturn("select * from h_v_KF_ICInventoryList_K3 where hmaterid=" + oSelectRow.BillMainID + " and hwhid=" + oSelectRow.BillSubID + " and hspid=" + oSelectRow.SPID + " and 批次='" + oSelectRow.BatchNo + "'", "h_v_KF_ICInventoryList_K3"); //写入信息 Sub_WriteInForm2(Ds.Tables[0], i); } //倒箱单 if (oSelectRow.BillType == "1240") { grdMain.Rows.Add(); grdMain.Rows[i].Cells[HTagCol].Value = "*"; //得到信息 Ds = oCn.RunProcReturn("select * from h_v_KF_ChangeBoxBillList_Source where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_KF_ChangeBoxBillList_Source"); //写入信息 Sub_WriteInForm3(Ds.Tables[0], i); } } // oSumGrid.Changelock = false; DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } //根据TABLE写入界面 private void Sub_WriteInForm(DataTable oTable, int i) { ////加载表头 //this.txtHDeptID.Tag = oTable.Rows[0]["HDeptID"].ToString(); //this.txtHDeptID.Text = oTable.Rows[0]["部门名称"].ToString(); ////加载表体 grdMain.Rows[i].Cells[HTagCol].Value = "*"; grdMain.Rows[i].Cells[HQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]); grdMain.Rows[i].Cells[HinitQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]); // grdMain.Rows[i].Cells[HMainIDCol].Value = oTable.Rows[0]["hmainid"].ToString(); grdMain.Rows[i].Cells[HSubIDCol].Value = oTable.Rows[0]["hsubid"].ToString(); grdMain.Rows[i].Cells[HBillNoCol].Value = oTable.Rows[0]["单据号"].ToString(); grdMain.Rows[i].Cells[HBillTypeCol].Value = oTable.Rows[0]["HBillType"].ToString(); grdMain.Rows[i].Cells[HDateCol].Value = oTable.Rows[0]["日期"].ToString(); grdMain.Rows[i].Cells[HSupIDCol].Value = oTable.Rows[0]["hsupid"].ToString(); grdMain.Rows[i].Cells[HSupNumberCol].Value = oTable.Rows[0]["供应商代码"].ToString(); grdMain.Rows[i].Cells[HSupNameCol].Value = oTable.Rows[0]["供应商"].ToString(); grdMain.Rows[i].Cells[HDeptIDCol].Value = oTable.Rows[0]["HDeptID"].ToString(); grdMain.Rows[i].Cells[HDeptNumberCol].Value = oTable.Rows[0]["部门代码"].ToString(); grdMain.Rows[i].Cells[HDeptNameCol].Value = oTable.Rows[0]["部门"].ToString(); grdMain.Rows[i].Cells[HMaterIDCol].Value = oTable.Rows[0]["HMaterID"].ToString(); grdMain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[0]["物料代码"].ToString(); grdMain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[0]["物料名称"].ToString(); grdMain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[0]["规格型号"].ToString(); grdMain.Rows[i].Cells[HBatchManagerCol].Value = oTable.Rows[0]["是否启用批次"].ToString(); grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[0]["批次"].ToString(); grdMain.Rows[i].Cells[HUnitIDCol].Value = oTable.Rows[0]["HUnitID"].ToString(); grdMain.Rows[i].Cells[HUnitNumberCol].Value = oTable.Rows[0]["计量单位代码"].ToString(); grdMain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[0]["计量单位"].ToString(); grdMain.Rows[i].Cells[HRemarkCol].Value = oTable.Rows[0]["备注"].ToString(); //grdMain.Rows[i].Cells[HDateCol].Value = string.Format("{0:yyyyMMdd}", ClsPub.isDate(ClsPub.GetServerDate(0))); //-- //设置可编辑列 string sAllowCol = HQtyCol.ToString() + "," + HMaterNameCol.ToString() + "," + HMaterModelCol.ToString() + "," + HPinfanCol.ToString() + "," + HMinQtyCol.ToString(); grdMain.Columns[HBillNoCol].ReadOnly = true; //设置合计列 string sTotalCol = HQtyCol.ToString(); // DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); tabControl1.SelectedIndex = 0; bc.Enabled = true; // RowCount(i, 0); } //根据TABLE写入界面(K3即时库存) private void Sub_WriteInForm2(DataTable oTable, int i) { ////加载表头 //this.txtHDeptID.Tag = oTable.Rows[0]["HDeptID"].ToString(); //this.txtHDeptID.Text = oTable.Rows[0]["部门名称"].ToString(); ////加载表体 grdMain.Rows[i].Cells[HTagCol].Value = "*"; grdMain.Rows[i].Cells[HQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["数量"]); grdMain.Rows[i].Cells[HinitQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["数量"]); // //grdMain.Rows[i].Cells[HMainIDCol].Value = oTable.Rows[0]["hmainid"].ToString(); //grdMain.Rows[i].Cells[HBillNoCol].Value = oTable.Rows[0]["任务单号"].ToString(); //grdMain.Rows[i].Cells[HBillTypeCol].Value = oTable.Rows[0]["HBillType"].ToString(); grdMain.Rows[i].Cells[HMaterIDCol].Value = oTable.Rows[0]["HMaterID"].ToString(); grdMain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[0]["物料代码"].ToString(); grdMain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[0]["物料名称"].ToString(); grdMain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[0]["规格型号"].ToString(); grdMain.Rows[i].Cells[HPinfanCol].Value = oTable.Rows[0]["品番"].ToString(); grdMain.Rows[i].Cells[HPinfanBarCodeCol].Value = oTable.Rows[0]["HPinfanBarCode"].ToString(); grdMain.Rows[i].Cells[HAuxPropIDCol].Value = oTable.Rows[0]["HAuxPropID"].ToString(); grdMain.Rows[i].Cells[HAuxPropNumberCol].Value = oTable.Rows[0]["辅助属性代码"].ToString(); grdMain.Rows[i].Cells[HAuxPropNameCol].Value = oTable.Rows[0]["辅助属性名称"].ToString(); grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[0]["批次"].ToString(); grdMain.Rows[i].Cells[HUnitIDCol].Value = oTable.Rows[0]["HUnitID"].ToString(); grdMain.Rows[i].Cells[HUnitNumberCol].Value = oTable.Rows[0]["计量单位代码"].ToString(); grdMain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[0]["计量单位"].ToString(); grdMain.Rows[i].Cells[HSupIDCol].Value = oTable.Rows[0]["HSupplyID"].ToString(); grdMain.Rows[i].Cells[HSupNumberCol].Value = oTable.Rows[0]["供应商代码"].ToString(); grdMain.Rows[i].Cells[HSupNameCol].Value = oTable.Rows[0]["供应商"].ToString(); grdMain.Rows[i].Cells[HWhIDCol].Value = oTable.Rows[0]["HWhID"].ToString(); grdMain.Rows[i].Cells[HWhNumberCol].Value = oTable.Rows[0]["仓库代码"].ToString(); grdMain.Rows[i].Cells[HWhNameCol].Value = oTable.Rows[0]["仓库"].ToString(); grdMain.Rows[i].Cells[HSPIDCol].Value = oTable.Rows[0]["HSPID"].ToString(); grdMain.Rows[i].Cells[HSPNumberCol].Value = oTable.Rows[0]["仓位代码"].ToString(); grdMain.Rows[i].Cells[HSPNameCol].Value = oTable.Rows[0]["仓位"].ToString(); grdMain.Rows[i].Cells[HDateCol].Value = ClsPub.GetServerDate(0); grdMain.Rows[i].Cells[HRemarkCol].Value = "按库存生成"; //grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value = oTable.Rows[0]["销售订单号"].ToString(); //获取最新最小包装数 SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet oDs = new DataSet(); oDs = oCn.RunProcReturn("exec h_p_Gy_StdPack " + oTable.Rows[0]["HMaterID"].ToString() + "," + oTable.Rows[0]["HAuxPropID"].ToString(), "h_p_Gy_StdPack"); // if (oDs != null && oDs.Tables[0].Rows.Count > 0) { grdMain.Rows[i].Cells[HMinQtyCol].Value = DBUtility.ClsPub.isSingle(oDs.Tables[0].Rows[0]["HMinPack"]); } //-- //设置可编辑列 string sAllowCol = HQtyCol.ToString() + "," + HRemarkCol.ToString() + "," + HMaterNameCol.ToString() + "," + HMaterModelCol.ToString() + "," + HPinfanCol.ToString() + "," + HMinQtyCol.ToString(); grdMain.Columns[HBillNoCol].ReadOnly = true; //设置合计列 string sTotalCol = HQtyCol.ToString(); // DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); tabControl1.SelectedIndex = 0; bc.Enabled = true; // RowCount(i, 0); } //根据TABLE写入界面(倒箱单) private void Sub_WriteInForm3(DataTable oTable, int i) { ////加载表头 //this.txtHDeptID.Tag = oTable.Rows[0]["HDeptID"].ToString(); //this.txtHDeptID.Text = oTable.Rows[0]["部门名称"].ToString(); ////加载表体 grdMain.Rows[i].Cells[HTagCol].Value = "*"; grdMain.Rows[i].Cells[HQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["可生成条码数量"]); grdMain.Rows[i].Cells[HinitQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["可生成条码数量"]); // grdMain.Rows[i].Cells[HMainIDCol].Value = oTable.Rows[0]["hmainid"].ToString(); grdMain.Rows[i].Cells[HSubIDCol].Value = oTable.Rows[0]["hsubid"].ToString(); grdMain.Rows[i].Cells[HBillNoCol].Value = oTable.Rows[0]["单据号"].ToString(); grdMain.Rows[i].Cells[HBillTypeCol].Value = oTable.Rows[0]["HBillType"].ToString(); grdMain.Rows[i].Cells[HDateCol].Value = oTable.Rows[0]["日期"].ToString(); grdMain.Rows[i].Cells[HDeptIDCol].Value = oTable.Rows[0]["HDeptID"].ToString(); grdMain.Rows[i].Cells[HDeptNumberCol].Value = oTable.Rows[0]["部门代码"].ToString(); grdMain.Rows[i].Cells[HDeptNameCol].Value = oTable.Rows[0]["部门"].ToString(); grdMain.Rows[i].Cells[HMaterIDCol].Value = oTable.Rows[0]["HMaterID"].ToString(); grdMain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[0]["物料代码"].ToString(); grdMain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[0]["物料名称"].ToString(); grdMain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[0]["规格型号"].ToString(); grdMain.Rows[i].Cells[HPinfanCol].Value = oTable.Rows[0]["品番"].ToString(); grdMain.Rows[i].Cells[HPinfanBarCodeCol].Value = oTable.Rows[0]["HPinfanBarCode"].ToString(); grdMain.Rows[i].Cells[HAuxPropIDCol].Value = oTable.Rows[0]["HAuxPropID"].ToString(); grdMain.Rows[i].Cells[HAuxPropNumberCol].Value = oTable.Rows[0]["辅助属性代码"].ToString(); grdMain.Rows[i].Cells[HAuxPropNameCol].Value = oTable.Rows[0]["辅助属性名称"].ToString(); grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[0]["批号"].ToString(); grdMain.Rows[i].Cells[HUnitIDCol].Value = oTable.Rows[0]["HUnitID"].ToString(); grdMain.Rows[i].Cells[HUnitNumberCol].Value = oTable.Rows[0]["计量单位代码"].ToString(); grdMain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[0]["计量单位"].ToString(); grdMain.Rows[i].Cells[HRemarkCol].Value = oTable.Rows[0]["备注"].ToString(); //获取最新最小包装数 SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet oDs = new DataSet(); oDs = oCn.RunProcReturn("exec h_p_Gy_StdPack " + oTable.Rows[0]["HMaterID"].ToString() + "," + oTable.Rows[0]["HAuxPropID"].ToString(), "h_p_Gy_StdPack"); // if (oDs != null && oDs.Tables[0].Rows.Count > 0) { grdMain.Rows[i].Cells[HMinQtyCol].Value = DBUtility.ClsPub.isSingle(oDs.Tables[0].Rows[0]["HMinPack"]); } //-- //设置可编辑列 string sAllowCol = HQtyCol.ToString() + "," + HRemarkCol.ToString() + "," + HMaterNameCol.ToString() + "," + HMaterModelCol.ToString() + "," + HPinfanCol.ToString() + "," + HMinQtyCol.ToString(); grdMain.Columns[HBillNoCol].ReadOnly = true; //设置合计列 string sTotalCol = HQtyCol.ToString(); // DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); tabControl1.SelectedIndex = 0; bc.Enabled = true; // RowCount(i, 0); } //网格编辑前判断 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); if (e.ColumnIndex == HMinQtyCol) { RowCount(e.RowIndex, 0); // } else if (e.ColumnIndex == HQtyCol) { 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; //预览 int CurRows = 0; 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(false); Thread.Sleep(1000); } //dy.Enabled = false; //yl.Enabled = false; } private void Sub_SetReport(string sOpenTmp) { //判断行数 for (int i = 0; i < grdSub.Rows.Count; i++) { grdSub.Rows[i].Cells[0].Value = "*"; //grdSub.Rows[i].Cells[0].Value = ""; } //for (int i = 0; i < grdSub.SelectedRows.Count; i++) //{ // grdSub.Rows[grdSub.SelectedRows[i].Index].Cells[0].Value = "*"; //} // Report = new GridppReport(); Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord); Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); } //填入单据表头信息 private void ReportBeforePostRecord()// { try { //Report.FieldByName("物料代码").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HMaterNumber2Col].Value); //Report.FieldByName("物料名称").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HMaterName2Col].Value); //Report.FieldByName("规格型号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HMaterModel2Col].Value); ////Report.FieldByName("自定义规格").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HModel2Col].Value); //Report.FieldByName("条码编号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HTMCol].Value); //Report.FieldByName("数量").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HQty2Col].Value); //Report.FieldByName("源单单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); //Report.FieldByName("销售订单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value); //Report.FieldByName("生产车间").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value); //Report.FieldByName("备注").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value); } catch (Exception e) { MessageBox.Show("打印失败!表头:" + e.Message); } } private void ReportFetchRecordByDataTable() { try { DataTable ds = new DataTable(); BLL.Utility.FillRecordToReport_Sel(Report, grdSub, ds, HSelectCol); } catch (Exception e) { MessageBox.Show("打印失败!表体:" + e.Message); } } private void dy_Click(object sender, EventArgs e) { //判断是否已经生成条码 if (DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value) == "") { MessageBox.Show("条码未生成,请先生成条码后再打印!"); return; } DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl(); //打印前判断条码是否已打印过 string sBarCode = ""; string sRelQty = ""; for (int i = 0; i < grdSub.Rows.Count; i++) { sBarCode =sBarCode +","+ DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[HTMCol].Value); } if (oBar.Set_BPrintQty(sBarCode.Substring(1), ref sRelQty)) { MessageBox.Show(sRelQty); return; } //选择打印模板 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.Print(false); Thread.Sleep(1000); } //批量更新条码打印次数 oBar.Set_EPrintQty(sBarCode.Substring(1)); } #endregion private void grdSub_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { int i = grdSub.CurrentCell.ColumnIndex; if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid, i)) { e.Cancel = true; } } private void grdSub_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; } } //选择 职员按钮 private void cmdHEmpID_Click(object sender, EventArgs e) { DAL.ClsK3_Employee_View oEmp = new DAL.ClsK3_Employee_View(); if (oEmp.RefreshView()) { this.txtHEmpID.Text = oEmp.oModel.HName; this.txtHEmpID.Tag = oEmp.oModel.HItemID.ToString(); } else { this.txtHEmpID.Text = ""; } } private void txtHEmpID_TextChanged(object sender, EventArgs e) { if (txtHEmpID.Text.Length == 0) { txtHEmpID.Tag = "0"; } } //选择 部门按钮 private void cmdHDeptID_Click_1(object sender, EventArgs e) { DAL.ClsK3_Department_View oDept = new DAL.ClsK3_Department_View(); if (oDept.RefreshView()) { this.txtHDeptID.Text = oDept.oModel.HName; this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString(); } else { this.txtHDeptID.Text = ""; } } private void txtHDeptID_TextChanged(object sender, EventArgs e) { if (txtHDeptID.Text.Length == 0) { txtHDeptID.Tag = "0"; } } //选择 班组按钮 private void cmdHGroupID_Click(object sender, EventArgs e) { DAL.ClsK3_Group_View oGroup = new DAL.ClsK3_Group_View();//K3班组 if (oGroup.RefreshView()) { this.txtHGroupID.Text = oGroup.oModel.HName; this.txtHGroupID.Tag = oGroup.oModel.HItemID.ToString(); } else { this.txtHGroupID.Text = ""; } } private void txtHGroupID_TextChanged(object sender, EventArgs e) { if (txtHGroupID.Text.Length == 0) { txtHGroupID.Tag = "0"; } } private void kc_Click(object sender, EventArgs e) { BLL.Cls_S_KF_ICInventoryList_K3 oadd = new BLL.Cls_S_KF_ICInventoryList_K3(); if (oadd.Refresh(" and HErpClsID in (1,2,3) ")) //选择原单 { FillSelectData(oadd.oBillSelectColl); } } //获取本月的第几周 private static int getWeekNumInMonth(DateTime daytime) { int dayInMonth = daytime.Day; //本月第一天 DateTime firstDay = daytime.AddDays(1 - daytime.Day); //本月第一天是周几 int weekday = (int)firstDay.DayOfWeek == 0 ? 7 : (int)firstDay.DayOfWeek; //本月第一周有几天 int firstWeekEndDay = 7 - (weekday - 1); //当前日期和第一周之差 int diffday = dayInMonth - firstWeekEndDay; diffday = diffday > 0 ? diffday : 1; //当前是第几周,如果整除7就减一天 int WeekNumInMonth = ((diffday % 7) == 0 ? (diffday / 7 - 1) : (diffday / 7)) + 1 + (dayInMonth > firstWeekEndDay ? 1 : 0); return WeekNumInMonth; } } }