| using System; | 
| using System.Collections.Generic; | 
| using System.ComponentModel; | 
| using System.Data; | 
| using System.Drawing; | 
| using System.Text; | 
| using System.Windows.Forms; | 
| using gregn6Lib; | 
| using Pub_Class; | 
| using System.Threading; | 
| using BLL; | 
|   | 
| namespace WarM | 
| { | 
|     public partial class K3_PoinStockList : Form | 
|     { | 
|         public K3_PoinStockList() | 
|         { | 
|             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 HSupIDCol = 6; | 
|         public const Int16 HSupNumberCol = 7; | 
|         public const Int16 HSupNameCol = 8; | 
|         public const Int16 HMaterIDCol = 9; | 
|         public const Int16 HMaterNumberCol = 10; | 
|         public const Int16 HMaterNameCol = 11; | 
|         public const Int16 HMaterModelCol = 12; | 
|         public const Int16 HModelCol = 13; | 
|         public const Int16 HBatchNoCol = 14; | 
|         public const Int16 HKFDateCol = 15;                    //,b.FKFDate 生产日期,b.FKFPeriod 保质期 | 
|         public const Int16 HKFPeriodCol = 16; | 
|         public const Int16 HKFDQDateCol = 17;     //到期日 | 
|         public const Int16 HUnitIDCol = 18; | 
|         public const Int16 HUnitNumberCol = 19; | 
|         public const Int16 HUnitNameCol = 20; | 
|         public const Int16 HQtyCol = 21; | 
|         public const Int16 HWXQtyCol = 22; | 
|         public const Int16 HMinQtyCol = 23; | 
|         public const Int16 HBQtyCol = 24; | 
|         public const Int16 HWBQtyCol = 25; | 
|         public const Int16 HDateCol = 26; | 
|         public const Int16 HSeOrderBillNoCol = 27; | 
|         public const Int16 HinitQtyCol = 28; | 
|         public const Int16 HwhidCol = 29; | 
|         public const Int16 HSPidCol = 30; | 
|          | 
|          | 
|   | 
|         public Int16 HSno2Col = 0; | 
|         public Int16 HTMCol = 1; | 
|         public Int16 HSupID2Col = 2; | 
|         public Int16 HSupNumber2Col = 3; | 
|         public Int16 HSupName2Col = 4; | 
|         public Int16 HMaterID2Col = 5; | 
|         public Int16 HMaterNumber2Col = 6; | 
|         public Int16 HMaterName2Col = 7; | 
|         public Int16 HMaterModel2Col = 8; | 
|         public Int16 HModel2Col = 9; | 
|         public Int16 HBatchNo2Col = 10; | 
|         public  Int16 HKFDate2Col = 11;                    //,b.FKFDate 生产日期,b.FKFPeriod 保质期 | 
|         public  Int16 HKFPeriod2Col = 12; | 
|         public  Int16 HKFDQDate2Col = 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 HSourceInterIDCol = 20; | 
|         public Int16 HSourceEntryIDCol = 21; | 
|         public Int16 HSourceBillNoCol = 22; | 
|         public Int16 HSourceBillTypeCol = 23; | 
|         public const Int16 HSeOrderBillNo2Col = 24; | 
|         public const Int16 HDateCol2 = 25; | 
|         public const Int16 HwhidCol2 = 26; | 
|         public const Int16 HSPidCol2 = 27; | 
|         public const Int16 HMinQtyCol2 = 28; | 
|   | 
|   | 
|   | 
|         // | 
|         public  string ModName = "72"; | 
|         public  string ModCaption = "KD外购件条码"; | 
|         public bool BillChange;   // | 
|          | 
|         public DBUtility.ClsPub.Enum_BillStatus BillStatus; | 
|         public Int64 KeyID; | 
|         public bool  grdStatus; | 
|         //public DAL.ClsK3_PoinStockList BillNew =new  DAL.ClsK3_PoinStockList(); | 
|         //public DAL.ClsK3_PoinStockList BillOld = new DAL.ClsK3_PoinStockList(); | 
|         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_PoinStockList(); | 
|             //    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"); | 
|             DBUtility.Xt_BaseBillFun.SaveGrid(grdSub2, this.Name + "grdSub2"); | 
|         } | 
|         //增行按钮   | 
|         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_PoinStockList_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_PoinStockList_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_PoinStockList(); | 
|             //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_PoinStockList(); | 
|             //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) | 
|         { | 
|             if (grdMain.Rows[0].Cells[HSubIDCol].Value != null)//HSubIDCol | 
|             { | 
|                 this.Sub_SaveBill(); | 
|             } | 
|             else | 
|             { | 
|                 MessageBox.Show("期初库存条码,必须单击入库按钮!"); | 
|             } | 
|         } | 
|         //放弃按钮 | 
|         private void fq_Click(object sender, EventArgs e) | 
|         { | 
|             this.Sub_AbandonBill(); | 
|         } | 
|         //审核按钮 | 
|         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_PoinStockList_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_PoinStockList_FormClosing(object sender, FormClosingEventArgs e) | 
|         { | 
|             BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; | 
|             DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); | 
|             DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub"); | 
|         } | 
|   | 
|         //新增单据 | 
|         private void Sub_AddBill() | 
|         { | 
|             //this.BillNew = new DAL.ClsK3_PoinStockList(); | 
|             //this.BillOld = new DAL.ClsK3_PoinStockList(); | 
|             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_PoinStockListSub 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; | 
|             //} | 
|             //明细表是否为零行 | 
|             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() | 
|         { | 
|             //SaveBarCodeByBatchNo(); | 
|             SaveBarCodeBySingle(); | 
|             return true; | 
|         } | 
|         //期初库存条码保存 | 
|         private bool Sub_SaveBill2() | 
|         { | 
|             //SaveBarCodeByBatchNo(); | 
|             SaveBarCodeBySingle2(); | 
|             return true; | 
|         } | 
|   | 
|         //生成条码(批次) | 
|         private void SaveBarCodeByBatchNo() | 
|         { | 
|             string TM = ""; | 
|             string HNumber = ""; | 
|             //double HQty = 0; | 
|             int HMinQty = 0; | 
|             int HBQty = 0; | 
|             int LSH = 0; | 
|             string LSH2 = ""; | 
|             int k = 0; | 
|             DataSet Ds; | 
|             SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|             Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "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[HMainIDCol].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.isInt(grdMain.Rows[j].Cells[HMinQtyCol].Value); | 
|   | 
|                     LSH = LSH + 1; | 
|                     LSH2 = LSH.ToString(); | 
|                     while (LSH2.Length < 4) | 
|                     { | 
|                         LSH2 = "0" + LSH2; | 
|                     } | 
|                     TM = HNumber + LSH2;  //条码 | 
|                     for (int i = k; i < HBQty; i++) | 
|                     { | 
|                         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[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[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; | 
|                         k = k + 1; | 
|                     } | 
|                 } | 
|             } | 
|             string HBarCode = ""; | 
|             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 = ""; | 
|             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(); | 
|                     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 = grdSub.Rows[i].Cells[HBatchNo2Col].Value.ToString(); | 
|                     HSupID = ClsPub.isLong(grdSub.Rows[i].Cells[HSupID2Col].Value); | 
|                     HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterIDCol].Value); | 
|                     HSourceEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceEntryIDCol].Value); | 
|                     HSourceBillNo = grdSub.Rows[i].Cells[HSourceBillNoCol].Value.ToString(); | 
|                     HSourceBillType = grdSub.Rows[i].Cells[HSourceBillTypeCol].Value.ToString(); | 
|                     oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HMaterID,HUnitID,HQty" + | 
|                                 ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty" + | 
|                                 ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType " + | 
|                                 ") values (" | 
|                                 + "'" + HBarCode + "'," + HMaterID + "," + HUnitID + "," + HQty2 | 
|                                 + ",'" + HBatchNo + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty | 
|                                 + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "')"); | 
|                     oCn.RunProc("exec setLSH '" + DateTime.Today + "'"); | 
|                 } | 
|             } | 
|             MessageBox.Show("条码生成完毕!");  | 
|         } | 
|   | 
|   | 
|         //生成条码(单品) | 
|         private void SaveBarCodeBySingle() | 
|         { | 
|             lblCaption.Focus(); | 
|             grdSub.Rows.Clear(); | 
|             grdSub2.Rows.Clear(); | 
|             int k = 0; | 
|             int F = 0; | 
|             DataSet Ds; | 
|             DataSet DsEr; | 
|             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) | 
|                 { | 
|                     //判断生成数量,是否超过单据未生成条码数量 | 
|                     long sMainID = ClsPub.isLong(grdMain.Rows[j].Cells[HMainIDCol].Value); | 
|                     long sSubID = ClsPub.isLong(grdMain.Rows[j].Cells[HSubIDCol].Value); | 
|                     long sMaterID = ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value); | 
|                     string sBillType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillTypeCol].Value); | 
|                     double sQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); | 
|                     //if (sMainID > 0) | 
|                     //{ | 
|                     //    DsEr = oCn.RunProcReturn("exec h_p_kf_CheckBarcodeRelationQty " + sMainID.ToString() + "," + sSubID.ToString() + "," + sMaterID.ToString() + ",'" + sBillType + "'," + sQty.ToString(), "gy_czygl"); | 
|                     //    if (DsEr == null || DsEr.Tables[0].Rows.Count == 0) | 
|                     //    { | 
|                     //        MessageBox.Show("判断已生成条码关联数时,出现错误!"); | 
|                     //        return; | 
|                     //    } | 
|                     //    if (ClsPub.isLong(DsEr.Tables[0].Rows[0][0]) != 9) | 
|                     //    { | 
|                     //        MessageBox.Show("需生成数量不能大于剩余数量!"); | 
|                     //        return; | 
|                     //    } | 
|                     //} | 
|                     string WeiShu = ""; //尾数 | 
|                     string TM = ""; | 
|                     string HNumber = ""; | 
|                     double HSumQty = 0; | 
|                     double HMinQty = 0; | 
|                     double HWXQty = 0; | 
|                     int HBQty = 0; | 
|                     int HWBQty = 0; | 
|                     int LSH = 0; | 
|                     string LSH2 = ""; | 
|                     string sDate = "";            //日期 | 
|                     string sYear = "";            //年 | 
|                     string sPeriod = "";            //月 | 
|                     string sDay = "";            //日 | 
|                     Ds = oCn.RunProcReturn("exec GetLSH " + sMaterID.ToString(), "GetLSH"); | 
|                     //Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH"); | 
|                     LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1; | 
|                     // | 
|                     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); | 
|                     HWXQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HWXQtyCol].Value); | 
|                     HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); | 
|                     HWBQty = HWBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HWBQtyCol].Value); | 
|                     // | 
|                     for (int i = 0; i < HWBQty; i++) | 
|                     { | 
|                         //流水号存档 | 
|                         oCn.RunProc("exec setLSH " + sMaterID.ToString()); | 
|                         // | 
|                         if (HSumQty - HWXQty > 0) | 
|                         { | 
|                             WeiShu = ""; | 
|                             HSumQty = HSumQty - HWXQty; | 
|                         } | 
|                         else | 
|                         { | 
|                             if (HSumQty == HWXQty) | 
|                             { | 
|                                 WeiShu = ""; | 
|                             } | 
|                             else | 
|                             { | 
|                                 WeiShu = "尾数"; | 
|                             } | 
|                             HWXQty = HSumQty; | 
|                         } | 
|                         // | 
|                         LSH2 = DBUtility.ClsPub.isStrNull(LSH + i); | 
|                         while (LSH2.Length < 6) | 
|                         { | 
|                             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 (k + 1 > grdSub.Rows.Count) | 
|                         { | 
|                             grdSub.RowCount = grdSub.RowCount + 1; | 
|                         } | 
|                         grdSub.Rows[k].Cells[HSno2Col].Value = ClsPub.isStrNull(k + 1); | 
|                         grdSub.Rows[k].Cells[HTMCol].Value = TM; | 
|                         grdSub.Rows[k].Cells[HSupID2Col].Value = grdMain.Rows[j].Cells[HSupIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HSupNumber2Col].Value = grdMain.Rows[j].Cells[HSupNumberCol].Value; | 
|                         grdSub.Rows[k].Cells[HSupName2Col].Value = grdMain.Rows[j].Cells[HSupNameCol].Value; | 
|   | 
|                         grdSub.Rows[k].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; | 
|                         grdSub.Rows[k].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; | 
|                         grdSub.Rows[k].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; | 
|                         grdSub.Rows[k].Cells[HModel2Col].Value = grdMain.Rows[j].Cells[HModelCol].Value; | 
|   | 
|                         grdSub.Rows[k].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; | 
|                         grdSub.Rows[k].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; | 
|   | 
|                         grdSub.Rows[k].Cells[HQty2Col].Value = HWXQty; | 
|                         //if (DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HDateCol].Value) != "") | 
|                         //{ | 
|                         //    grdSub.Rows[k].Cells[HBatchNo2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HDateCol].Value) + "-" + DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value); | 
|                         //} | 
|                         //else | 
|                         //{ | 
|                         //    grdSub.Rows[k].Cells[HBatchNo2Col].Value = ""; | 
|                         //} | 
|                         grdSub.Rows[k].Cells[HBatchNo2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value); | 
|                         grdSub.Rows[k].Cells[HKFDate2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HKFDateCol].Value); | 
|                         grdSub.Rows[k].Cells[HKFPeriod2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HKFPeriodCol].Value); | 
|                         //grdSub.Rows[k].Cells[HKFPeriod2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HKFPeriodCol].Value); | 
|                         grdSub.Rows[k].Cells[HKFDQDate2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HKFDQDateCol].Value); | 
|                         grdSub.Rows[k].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HSourceEntryIDCol].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HSourceBillNoCol].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; | 
|                         grdSub.Rows[k].Cells[HSourceBillTypeCol].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; | 
|                         grdSub.Rows[k].Cells[HPrintCol].Value = "0"; | 
|                         grdSub.Rows[k].Cells[HWeiCol].Value = WeiShu; | 
|                         grdSub.Rows[k].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value; | 
|                         grdSub.Rows[k].Cells[HMinQtyCol2].Value = grdMain.Rows[j].Cells[HMinQtyCol].Value; | 
|                         k = k + 1; | 
|                     } | 
|   | 
|                 } | 
|                 else | 
|                 { | 
|                     continue; | 
|                 } | 
|             } | 
|             k = 0; | 
|             for (int g = 0; g < grdSub.Rows.Count; g++) | 
|             { | 
|                 if (ClsPub.isLong(grdSub.Rows[g].Cells[HMaterID2Col].Value) != 0) | 
|                 { | 
|                     long sMaterID = ClsPub.isLong(grdSub.Rows[g].Cells[HMaterID2Col].Value); | 
|                     Ds = oCn.RunProcReturn("exec GetLSH " + sMaterID.ToString(), "GetLSH"); | 
|                     string WeiShu = ""; //尾数 | 
|                     string TM = ""; | 
|                     string HNumber = ""; | 
|                     double HSumQty = 0; | 
|                     double HMinQty = 0; | 
|                     double HWXQty = 0; | 
|                     int HBQty = 0; | 
|                     int HWBQty = 0; | 
|                     int LSH = 0; | 
|                     string LSH2 = ""; | 
|                     string sDate = "";            //日期 | 
|                     string sYear = "";            //年 | 
|                     string sPeriod = "";            //月 | 
|                     string sDay = "";            //日 | 
|                     LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1; | 
|                     // | 
|                     HNumber = grdSub.Rows[g].Cells[HMaterID2Col].Value.ToString(); | 
|                     //HNumber = HNumber.Replace(".", ""); | 
|                     //////////HBQty = HBQty + ClsPub.isInt(grdSub.Rows[g].Cells[HBQtyCol2].Value); | 
|                     HMinQty = ClsPub.isDoule(grdSub.Rows[g].Cells[HMinQtyCol2].Value); | 
|                     HWXQty = ClsPub.isDoule(grdSub.Rows[g].Cells[HQty2Col].Value); | 
|                     HSumQty = ClsPub.isDoule(grdSub.Rows[g].Cells[HQty2Col].Value); | 
|                     //////////HWBQty = HWBQty + ClsPub.isInt(grdMain.Rows[g].Cells[HWBQtyCol].Value); | 
|                     //HMinQty = ClsPub.isDoule(grdMain.Rows[g].Cells[HMinQtyCol].Value); | 
|                     //HWXQty = ClsPub.isDoule(grdSub.Rows[g].Cells[HQty2Col].Value); | 
|                     //float HBQty2 = Convert.ToSingle(HBQty); | 
|                     //float HBQty3 = Convert.ToSingle(grdSub.Rows.Count); | 
|                     //int l = Convert.ToInt32(Math.Ceiling(HBQty2 / HBQty3)); | 
|                     double NXTMQTY = 0; | 
|                     for (int i = 0; i < 10000; i++) | 
|                     { | 
|                         if (HSumQty <= 0 ||  HMinQty <=0 ) | 
|                         { | 
|                             break; | 
|                         } | 
|                         int q = i + 1; | 
|                         // | 
|                         if (HSumQty - HMinQty > 0) | 
|                         { | 
|                             WeiShu = ""; | 
|                             NXTMQTY = HMinQty; | 
|                             HSumQty = HSumQty - HMinQty; | 
|                         } | 
|                         else | 
|                         { | 
|                             if (HSumQty == HMinQty) | 
|                             { | 
|                                 WeiShu = ""; | 
|                             } | 
|                             else | 
|                             { | 
|                                 WeiShu = "尾数"; | 
|                             } | 
|                             NXTMQTY = HSumQty;  //HWXQty | 
|                             HSumQty = 0; | 
|                         } | 
|                         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; //条码 | 
|                         // | 
|                         if (k + 1 > grdSub2.Rows.Count) | 
|                         { | 
|                             grdSub2.RowCount = grdSub2.RowCount + 1; | 
|                         } | 
|                         grdSub2.Rows[k].Cells[HSno2Col].Value = ClsPub.isStrNull(k + 1); | 
|                         grdSub2.Rows[k].Cells[HMaterID2Col].Value = grdSub.Rows[g].Cells[HMaterID2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HMaterNumber2Col].Value = grdSub.Rows[g].Cells[HMaterNumber2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HMaterName2Col].Value = grdSub.Rows[g].Cells[HMaterName2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HMaterModel2Col].Value = grdSub.Rows[g].Cells[HMaterModel2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HModel2Col].Value = grdSub.Rows[g].Cells[HModel2Col].Value; | 
|   | 
|                         grdSub2.Rows[k].Cells[HTMCol].Value = TM + grdSub.Rows[g].Cells[HTMCol].Value + "-00" + i.ToString(); | 
|                         grdSub2.Rows[k].Cells[HSupID2Col].Value = grdSub.Rows[g].Cells[HSupID2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HSupNumber2Col].Value = grdSub.Rows[g].Cells[HSupNumber2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HSupName2Col].Value = grdSub.Rows[g].Cells[HSupName2Col].Value; | 
|   | 
|                         grdSub2.Rows[k].Cells[HUnitID2Col].Value = grdSub.Rows[g].Cells[HUnitID2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HUnitNumber2Col].Value = grdSub.Rows[g].Cells[HUnitNumber2Col].Value; | 
|                         grdSub2.Rows[k].Cells[HUnitName2Col].Value = grdSub.Rows[g].Cells[HUnitName2Col].Value; | 
|   | 
|                         grdSub2.Rows[k].Cells[HQty2Col].Value = HMinQty; | 
|                         grdSub2.Rows[k].Cells[HBatchNo2Col].Value = DBUtility.ClsPub.isStrNull(grdSub.Rows[g].Cells[HBatchNo2Col].Value); | 
|                         grdSub2.Rows[k].Cells[HKFDate2Col].Value = DBUtility.ClsPub.isStrNull(grdSub.Rows[g].Cells[HKFDate2Col].Value); | 
|                         grdSub2.Rows[k].Cells[HKFPeriod2Col].Value = DBUtility.ClsPub.isStrNull(grdSub.Rows[g].Cells[HKFPeriod2Col].Value); | 
|                         grdSub2.Rows[k].Cells[HKFDQDate2Col].Value = DBUtility.ClsPub.isStrNull(grdSub.Rows[g].Cells[HKFDQDate2Col].Value); | 
|                         grdSub2.Rows[k].Cells[HSourceInterIDCol].Value = grdSub.Rows[g].Cells[HSourceInterIDCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSourceEntryIDCol].Value = grdSub.Rows[g].Cells[HSourceEntryIDCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSourceBillNoCol].Value = grdSub.Rows[g].Cells[HSourceBillNoCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSourceBillTypeCol].Value = grdSub.Rows[g].Cells[HSourceBillTypeCol].Value; | 
|                         grdSub2.Rows[k].Cells[HPrintCol].Value = "0"; | 
|                         grdSub2.Rows[k].Cells[HWeiCol].Value = WeiShu; | 
|                         grdSub2.Rows[k].Cells[HSeOrderBillNo2Col].Value = grdSub.Rows[g].Cells[HSeOrderBillNo2Col].Value; | 
|                         k = k + 1; | 
|                     } | 
|                 } | 
|             }      | 
|             string HWei = "";      //尾数 | 
|             string HBarCode = ""; | 
|             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 HKFDate = ""; | 
|             Int64 HKFPeriod = 0; | 
|             string HKFDQDate = ""; | 
|             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); | 
|                         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); | 
|                         HSupID = ClsPub.isLong(grdSub.Rows[i].Cells[HSupID2Col].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); | 
|                         HKFDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HKFDate2Col].Value); | 
|                         HKFPeriod = ClsPub.isLong(grdSub.Rows[i].Cells[HKFPeriod2Col].Value); | 
|                         HKFDQDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HKFDQDate2Col].Value); | 
|                         oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + | 
|                                     ",HBatchNo,HSupID,HGroupID,HDeptID,HMaker,HMakeDate,HPrintQty" + | 
|                                     ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty,HBarCodeType" + | 
|                                     ") values (" | 
|                                     + "'" + HBarCode + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate | 
|                                     + "','" + HBatchNo + "'," + HSupID + "," + HGroupID + "," + HDeptID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty | 
|                                     + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "','外箱条码')"); | 
|                     } | 
|                 } | 
|                 for (int i = 0; i < grdSub2.Rows.Count; i++) | 
|                 { | 
|                     if (ClsPub.isLong(grdSub2.Rows[i].Cells[HMaterID2Col].Value) != 0) | 
|                     { | 
|                         HWei = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HWeiCol].Value); | 
|                         HDeptID = ClsPub.isLong(txtHDeptID.Tag); | 
|                         HBarCode = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HTMCol].Value); | 
|                         HMaterID = ClsPub.isLong(grdSub2.Rows[i].Cells[HMaterID2Col].Value); | 
|                         HUnitID = ClsPub.isLong(grdSub2.Rows[i].Cells[HUnitID2Col].Value); | 
|                         HQty2 = ClsPub.isDoule(grdSub2.Rows[i].Cells[HQty2Col].Value); | 
|                         HBatchNo = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HBatchNo2Col].Value); | 
|                         HSupID = ClsPub.isLong(grdSub2.Rows[i].Cells[HSupID2Col].Value); | 
|                         HSourceInterID = ClsPub.isLong(grdSub2.Rows[i].Cells[HSourceInterIDCol].Value); | 
|                         HSourceEntryID = ClsPub.isLong(grdSub2.Rows[i].Cells[HSourceEntryIDCol].Value); | 
|                         HSourceBillNo = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HSourceBillNoCol].Value); | 
|                         HSourceBillType = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HSourceBillTypeCol].Value); | 
|                         HKFDate = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HKFDate2Col].Value); | 
|                         HKFPeriod = ClsPub.isLong(grdSub2.Rows[i].Cells[HKFPeriod2Col].Value); | 
|                         oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + | 
|                                     ",HBatchNo,HSupID,HGroupID,HDeptID,HMaker,HMakeDate,HPrintQty" + | 
|                                     ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty,HStopflag,HBarCodeType" + | 
|                                     ") values (" | 
|                                     + "'" + HBarCode + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate | 
|                                     + "','" + HBatchNo + "'," + HSupID + "," + HGroupID + "," + HDeptID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty | 
|                                     + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "',0,'内箱条码')"); | 
|                     } | 
|                 } | 
|                 oCn.Commit(); | 
|                 MessageBox.Show("条码生成完毕!"); | 
|                 tabControl1.SelectedIndex = 1; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 oCn.RollBack(); | 
|                 MessageBox.Show("条码生成失败!" + e.Message); | 
|             } | 
|         } | 
|         public static Int64 CreateBillID_K3(string BillCode, ref string sReturn) | 
|         { | 
|             SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3(); | 
|             DataSet Ds1; | 
|             long HInterID = 0; | 
|             try | 
|             { | 
|                 Ds1 = oCnK3.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNumOld  '" + BillCode + "',@InterID output select ltrim(@InterID)", "xt_xtgnb"); | 
|                 if (Ds1.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     HInterID = DBUtility.ClsPub.isLong(Ds1.Tables[0].Rows[0][0]); | 
|                     return HInterID; | 
|                 } | 
|                 else | 
|                 { | 
|                     return 0; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 return 0; | 
|             } | 
|         } | 
|         //期初库存条码生成 | 
|         private void SaveBarCodeBySingle2() | 
|         { | 
|             string sErrMsg = string.Empty; | 
|             lblCaption.Focus(); | 
|             grdSub.Rows.Clear(); | 
|             grdSub2.Rows.Clear(); | 
|             int k = 0; | 
|             int F = 0; | 
|             int s = 0; | 
|             DataSet Ds; | 
|             DataSet Ds2; | 
|             DataSet Ds3; | 
|             DataSet DsEr; | 
|             SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|             Ds3 = oCn.RunProcReturn("exec ICStockBillCode ", "ICStockBillCode"); | 
|             Ds2 = oCn.RunProcReturn("exec Xt_GetMaxBillID '1203' ", "ICStockBillCode"); | 
|             // Int64 HInterID2 = CreateBillID_K3("ICStockBill", ref sErrMsg); exec Xt_GetMaxBillID '1203' | 
|             for (int j = 0; j < grdMain.Rows.Count; j++) | 
|             { | 
|                 if (ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value) != 0) | 
|                 { | 
|                     //判断生成数量,是否超过单据未生成条码数量 | 
|                     long sMainID = ClsPub.isLong(grdMain.Rows[j].Cells[HMainIDCol].Value); | 
|                     long sSubID = ClsPub.isLong(grdMain.Rows[j].Cells[HSubIDCol].Value); | 
|                     long sMaterID = ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value); | 
|                     string sBillType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillTypeCol].Value); | 
|                     double sQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); | 
|                     string WeiShu = ""; //尾数 | 
|                     string TM = ""; | 
|                     string HNumber = ""; | 
|                     double HSumQty = 0; | 
|                     double HMinQty = 0; | 
|                     double HWXQty = 0; | 
|                     int HBQty = 0; | 
|                     int HWBQty = 0; | 
|                     int LSH = 0; | 
|                     string LSH2 = ""; | 
|                     string sDate = "";            //日期 | 
|                     string sYear = "";            //年 | 
|                     string sPeriod = "";            //月 | 
|                     string sDay = "";            //日 | 
|                     Ds = oCn.RunProcReturn("exec GetLSH " + sMaterID.ToString(), "GetLSH"); | 
|                     //Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH"); | 
|                     LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1; | 
|                     // | 
|                     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); | 
|                     HWXQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HWXQtyCol].Value); | 
|                     HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); | 
|                     HWBQty = HWBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HWBQtyCol].Value); | 
|                     // | 
|                     for (int i = 0; i < HWBQty; i++) | 
|                     { | 
|                         //流水号存档 | 
|                         oCn.RunProc("exec setLSH " + sMaterID.ToString()); | 
|                         // | 
|                         if (HSumQty - HWXQty > 0) | 
|                         { | 
|                             WeiShu = ""; | 
|                             HSumQty = HSumQty - HWXQty; | 
|                         } | 
|                         else | 
|                         { | 
|                             if (HSumQty == HWXQty) | 
|                             { | 
|                                 WeiShu = ""; | 
|                             } | 
|                             else | 
|                             { | 
|                                 WeiShu = "尾数"; | 
|                             } | 
|                             HWXQty = HSumQty; | 
|                         } | 
|                         // | 
|                         LSH2 = DBUtility.ClsPub.isStrNull(LSH + i); | 
|                         while (LSH2.Length < 6) | 
|                         { | 
|                             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 (k + 1 > grdSub.Rows.Count) | 
|                         { | 
|                             grdSub.RowCount = grdSub.RowCount + 1; | 
|                         } | 
|                         grdSub.Rows[k].Cells[HSno2Col].Value = ClsPub.isStrNull(k + 1); | 
|                         grdSub.Rows[k].Cells[HTMCol].Value = TM; | 
|                         grdSub.Rows[k].Cells[HSupID2Col].Value = grdMain.Rows[j].Cells[HSupIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HSupNumber2Col].Value = grdMain.Rows[j].Cells[HSupNumberCol].Value; | 
|                         grdSub.Rows[k].Cells[HSupName2Col].Value = grdMain.Rows[j].Cells[HSupNameCol].Value; | 
|   | 
|                         grdSub.Rows[k].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; | 
|                         grdSub.Rows[k].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; | 
|                         grdSub.Rows[k].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; | 
|                         grdSub.Rows[k].Cells[HModel2Col].Value = grdMain.Rows[j].Cells[HModelCol].Value; | 
|   | 
|                         grdSub.Rows[k].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; | 
|                         grdSub.Rows[k].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; | 
|                         grdSub.Rows[k].Cells[HQty2Col].Value = HWXQty; | 
|   | 
|                         //if (DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HDateCol].Value) != "") | 
|                         //{ | 
|                         //    grdSub.Rows[k].Cells[HBatchNo2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HDateCol].Value) + "-" + DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value); | 
|                         //} | 
|                         //else | 
|                         //{ | 
|                         //    grdSub.Rows[k].Cells[HBatchNo2Col].Value = ""; | 
|                         //} | 
|                         grdSub.Rows[k].Cells[HBatchNo2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value); | 
|                         grdSub.Rows[k].Cells[HKFDate2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HKFDateCol].Value); | 
|                         grdSub.Rows[k].Cells[HKFPeriod2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HKFPeriodCol].Value); | 
|                         grdSub.Rows[k].Cells[HKFDQDate2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HKFDQDateCol].Value); | 
|                         grdSub.Rows[k].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HSourceEntryIDCol].Value = grdMain.Rows[j].Cells[HSubIDCol].Value; | 
|                         grdSub.Rows[k].Cells[HSourceBillNoCol].Value = grdMain.Rows[j].Cells[HBillNoCol].Value; | 
|                         grdSub.Rows[k].Cells[HSourceBillTypeCol].Value = grdMain.Rows[j].Cells[HBillTypeCol].Value; | 
|                         grdSub.Rows[k].Cells[HPrintCol].Value = "0"; | 
|                         grdSub.Rows[k].Cells[HWeiCol].Value = WeiShu; | 
|                         grdSub.Rows[k].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value; | 
|                         grdSub.Rows[k].Cells[HwhidCol2].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HwhidCol].Value);//grdMain.Columns[HSPidCol] | 
|                         grdSub.Rows[k].Cells[HSPidCol2].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HSPidCol].Value); | 
|                         k = k + 1; | 
|                     } | 
|   | 
|                 } | 
|                 else | 
|                 { | 
|                     continue; | 
|                 } | 
|             } | 
|             k = 0; | 
|             for (int g = 0; g < grdSub.Rows.Count; g++) | 
|             { | 
|                 if (ClsPub.isLong(grdSub.Rows[g].Cells[HMaterID2Col].Value) != 0) | 
|                 { | 
|                     long sMaterID = ClsPub.isLong(grdMain.Rows[g].Cells[HMaterID2Col].Value); | 
|                     Ds = oCn.RunProcReturn("exec GetLSH " + sMaterID.ToString(), "GetLSH"); | 
|                     string WeiShu = ""; //尾数 | 
|                     string TM = ""; | 
|                     string HNumber = ""; | 
|                     double HSumQty = 0; | 
|                     double HMinQty = 0; | 
|   | 
|                     double HWXQty = 0; | 
|                     double HWXQty1 = 0; | 
|                     int HBQty = 0; | 
|                     int HWBQty = 0; | 
|                     int LSH = 0; | 
|                     string LSH2 = ""; | 
|                     string sDate = "";            //日期 | 
|                     string sYear = "";            //年 | 
|                     string sPeriod = "";            //月 | 
|                     string sDay = "";            //日 | 
|                     LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1; | 
|                     // | 
|                     HNumber = grdSub.Rows[g].Cells[HMaterID2Col].Value.ToString(); | 
|                     HBQty = HBQty + ClsPub.isInt(grdMain.Rows[g].Cells[HBQtyCol].Value); | 
|                     HMinQty = ClsPub.isDoule(grdMain.Rows[g].Cells[HMinQtyCol].Value); | 
|                     HWXQty = ClsPub.isDoule(grdMain.Rows[g].Cells[HWXQtyCol].Value); | 
|                     HSumQty = ClsPub.isDoule(grdMain.Rows[g].Cells[HQtyCol].Value); | 
|                     HWBQty = HWBQty + ClsPub.isInt(grdMain.Rows[g].Cells[HWBQtyCol].Value); | 
|                     HMinQty = ClsPub.isDoule(grdMain.Rows[g].Cells[HMinQtyCol].Value); | 
|                     HWXQty = ClsPub.isDoule(grdSub.Rows[g].Cells[HQty2Col].Value); | 
|                     HWXQty1 = ClsPub.isDoule(grdSub.Rows[g].Cells[HQty2Col].Value); | 
|                     for (int i = 0; i < HBQty; i++) | 
|                     { | 
|                         int q = i + 1; | 
|                         // | 
|                         if (HWXQty - HMinQty > 0) | 
|                         { | 
|                             WeiShu = ""; | 
|                             HWXQty = HWXQty - HMinQty; | 
|                         } | 
|                         else | 
|                         { | 
|                             if (HWXQty == HMinQty) | 
|                             { | 
|                                 WeiShu = ""; | 
|                             } | 
|                             else | 
|                             { | 
|                                 WeiShu = "尾数"; | 
|                             } | 
|                             HMinQty = HWXQty;  //HWXQty | 
|                         } | 
|                         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; //条码 | 
|                         // | 
|                         if (k + 1 > grdSub2.Rows.Count) | 
|                         { | 
|                             grdSub2.RowCount = grdSub2.RowCount + 1; | 
|                         } | 
|                         grdSub2.Rows[k].Cells[HSno2Col].Value = ClsPub.isStrNull(k + 1); | 
|                         grdSub2.Rows[k].Cells[HMaterID2Col].Value = grdMain.Rows[g].Cells[HMaterIDCol].Value; | 
|                         grdSub2.Rows[k].Cells[HMaterNumber2Col].Value = grdMain.Rows[g].Cells[HMaterNumberCol].Value; | 
|                         grdSub2.Rows[k].Cells[HMaterName2Col].Value = grdMain.Rows[g].Cells[HMaterNameCol].Value; | 
|                         grdSub2.Rows[k].Cells[HMaterModel2Col].Value = grdMain.Rows[g].Cells[HMaterModelCol].Value; | 
|                         grdSub2.Rows[k].Cells[HModel2Col].Value = grdMain.Rows[g].Cells[HModelCol].Value; | 
|                         grdSub2.Rows[k].Cells[HTMCol].Value = grdSub.Rows[s].Cells[HTMCol].Value + "00" + q.ToString(); | 
|                         //if (HWXQty1 - HMinQty <=0) | 
|                         //{ | 
|                         //    s++; | 
|                         //    if (grdSub.Rows.Count >= s) | 
|                         //    { | 
|                         //        HWXQty1 = ClsPub.isDoule(grdSub.Rows[s].Cells[HQty2Col].Value); | 
|                         //    } | 
|                         //} | 
|                         //else | 
|                         //{ | 
|                         //    grdSub2.Rows[k].Cells[HTMCol].Value = grdSub.Rows[s].Cells[HTMCol].Value + "00" + q.ToString(); | 
|                         //    HWXQty1 = HWXQty1 - HMinQty; | 
|                         //} | 
|   | 
|                         grdSub2.Rows[k].Cells[HSupID2Col].Value = grdMain.Rows[g].Cells[HSupIDCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSupNumber2Col].Value = grdMain.Rows[g].Cells[HSupNumberCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSupName2Col].Value = grdMain.Rows[g].Cells[HSupNameCol].Value; | 
|   | 
|                         grdSub2.Rows[k].Cells[HUnitID2Col].Value = grdMain.Rows[g].Cells[HUnitIDCol].Value; | 
|                         grdSub2.Rows[k].Cells[HUnitNumber2Col].Value = grdMain.Rows[g].Cells[HUnitNumberCol].Value; | 
|                         grdSub2.Rows[k].Cells[HUnitName2Col].Value = grdMain.Rows[g].Cells[HUnitNameCol].Value; | 
|   | 
|                         grdSub2.Rows[k].Cells[HQty2Col].Value = HMinQty; | 
|   | 
|                         grdSub2.Rows[k].Cells[HBatchNo2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[g].Cells[HBatchNoCol].Value); | 
|                         grdSub2.Rows[k].Cells[HKFDate2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[g].Cells[HKFDateCol].Value); | 
|                         grdSub2.Rows[k].Cells[HKFPeriod2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[g].Cells[HKFPeriodCol].Value); | 
|                         grdSub2.Rows[k].Cells[HKFDQDate2Col].Value = DBUtility.ClsPub.isStrNull(grdMain.Rows[g].Cells[HKFDQDateCol].Value); | 
|                         grdSub2.Rows[k].Cells[HSourceInterIDCol].Value = grdMain.Rows[g].Cells[HMainIDCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSourceEntryIDCol].Value = grdMain.Rows[g].Cells[HSubIDCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSourceBillNoCol].Value = grdMain.Rows[g].Cells[HBillNoCol].Value; | 
|                         grdSub2.Rows[k].Cells[HSourceBillTypeCol].Value = grdMain.Rows[g].Cells[HBillTypeCol].Value; | 
|                         grdSub2.Rows[k].Cells[HPrintCol].Value = "0"; | 
|                         grdSub2.Rows[k].Cells[HWeiCol].Value = WeiShu; | 
|                         grdSub2.Rows[k].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[g].Cells[HSeOrderBillNoCol].Value;                     | 
|                         k = k + 1; | 
|                     } | 
|                 } | 
|             } | 
|             string HWei = "";      //尾数 | 
|             string HBarCode = ""; | 
|             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 HKFDate = ""; | 
|             string HKFDQDate = ""; | 
|             Int64 HKFPeriod = 0; | 
|             Int64 HInterID = 0; | 
|             Int64 HEntryID = 0; | 
|             Int64 Hwhid = 0; | 
|             Int64 HSPid = 0; | 
|             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); | 
|                         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); | 
|                         HSupID = ClsPub.isLong(grdSub.Rows[i].Cells[HSupID2Col].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); | 
|                         HKFDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HKFDate2Col].Value); | 
|                         HKFPeriod = ClsPub.isLong(grdSub.Rows[i].Cells[HKFPeriod2Col].Value); | 
|                         HKFDQDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HKFDQDate2Col].Value); | 
|                         oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + | 
|                                     ",HBatchNo,HSupID,HGroupID,HDeptID,HMaker,HMakeDate,HPrintQty" + | 
|                                     ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty,HBarCodeType" + | 
|                                     ") values (" | 
|                                     + "'" + HBarCode + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate | 
|                                     + "','" + HBatchNo + "'," + HSupID + "," + HGroupID + "," + HDeptID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty | 
|                                     + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "','外箱条码')"); | 
|                     } | 
|                 } | 
|                 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); | 
|                         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); | 
|                       //  HSupID = ClsPub.isLong(grdSub.Rows[i].Cells[HSupID2Col].Value); | 
|                         HSourceInterID = ClsPub.isLong(Ds3.Tables[0].Rows[0][0]);//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); | 
|                         HKFDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HKFDate2Col].Value); | 
|                         HKFPeriod = ClsPub.isLong(grdSub.Rows[i].Cells[HKFPeriod2Col].Value); | 
|                         HInterID = ClsPub.isLong(Ds2.Tables[0].Rows[0][0]); | 
|                         HEntryID = i + 1; | 
|                         Hwhid = ClsPub.isLong(grdSub.Rows[i].Cells[HwhidCol2].Value); | 
|                         HSPid = ClsPub.isLong(grdSub.Rows[i].Cells[HSPidCol2].Value); | 
|                         oCn.RunProc("insert into Kf_ICStockBillSub_WMS (HInterID,HBillType,HEntryID,HProcID,HAddr,HSourceItemID,HWhID,HStockPlaceid,HBarCode,HMaterID,HQty,HKFDate,HKFPeriod,HKFDQDate" + | 
|                                     ",HBatchNo,HGroupID,HMaker,HMakeDate" + | 
|                                     ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType " + | 
|                                     ") values (" | 
|                                     + HInterID + ",10," + HEntryID + ",0,'',0," + Hwhid + "," + HSPid + ",'" + HBarCode + "'," + HMaterID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate | 
|                                     + "','" + HBatchNo  + "'," + HGroupID + ",'" + ClsPub.CurUserName + "',getdate()"  | 
|                                     + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "')"); | 
|                     } | 
|                 } | 
|                 for (int i = 0; i < grdSub2.Rows.Count; i++) | 
|                 { | 
|                     if (ClsPub.isLong(grdSub2.Rows[i].Cells[HMaterID2Col].Value) != 0) | 
|                     { | 
|                         HWei = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HWeiCol].Value); | 
|                         HDeptID = ClsPub.isLong(txtHDeptID.Tag); | 
|                         HBarCode = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HTMCol].Value); | 
|                         HMaterID = ClsPub.isLong(grdSub2.Rows[i].Cells[HMaterID2Col].Value); | 
|                         HUnitID = ClsPub.isLong(grdSub2.Rows[i].Cells[HUnitID2Col].Value); | 
|                         HQty2 = ClsPub.isDoule(grdSub2.Rows[i].Cells[HQty2Col].Value); | 
|                         HBatchNo = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HBatchNo2Col].Value); | 
|                         HSupID = ClsPub.isLong(grdSub2.Rows[i].Cells[HSupID2Col].Value); | 
|                         HSourceInterID = ClsPub.isLong(grdSub2.Rows[i].Cells[HSourceInterIDCol].Value); | 
|                         HSourceEntryID = ClsPub.isLong(grdSub2.Rows[i].Cells[HSourceEntryIDCol].Value); | 
|                         HSourceBillNo = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HSourceBillNoCol].Value); | 
|                         HSourceBillType = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HSourceBillTypeCol].Value); | 
|                         HKFDate = ClsPub.isStrNull(grdSub2.Rows[i].Cells[HKFDate2Col].Value); | 
|                         HKFPeriod = ClsPub.isLong(grdSub2.Rows[i].Cells[HKFPeriod2Col].Value); | 
|                         oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" + | 
|                                     ",HBatchNo,HSupID,HGroupID,HDeptID,HMaker,HMakeDate,HPrintQty" + | 
|                                     ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty,HStopflag,HBarCodeType" + | 
|                                     ") values (" | 
|                                     + "'" + HBarCode + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate | 
|                                     + "','" + HBatchNo + "'," + HSupID + "," + HGroupID + "," + HDeptID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty | 
|                                     + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "',0,'内箱条码')"); | 
|                     } | 
|                 } | 
|                 oCn.Commit(); | 
|                 MessageBox.Show("条码生成完毕!"); | 
|                 tabControl1.SelectedIndex = 1; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 oCn.RollBack(); | 
|                 MessageBox.Show("条码生成失败!" + e.Message); | 
|             } | 
|         } | 
|   | 
|   | 
|         #endregion  | 
|   | 
|   | 
|         #region 窗体处理方法 | 
|         //初始化GRID | 
|         private void initGrid() | 
|         { | 
|             // | 
|             grdMain.ColumnCount = 31;                       //总列数 | 
|             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[HSupIDCol].HeaderText = "供应商ID"; | 
|             grdMain.Columns[HSupNumberCol].HeaderText = "供应商代码"; | 
|             grdMain.Columns[HSupNameCol].HeaderText = "供应商名称"; | 
|             grdMain.Columns[HMaterIDCol].HeaderText = "物料ID"; | 
|             grdMain.Columns[HMaterNumberCol].HeaderText = "物料代码"; | 
|             grdMain.Columns[HMaterNameCol].HeaderText = "物料名称"; | 
|             grdMain.Columns[HMaterModelCol].HeaderText = "规格型号"; | 
|             grdMain.Columns[HModelCol].HeaderText = "自定义规格"; | 
|             grdMain.Columns[HBatchNoCol].HeaderText = "批号"; | 
|             grdMain.Columns[HUnitIDCol].HeaderText = "单位ID"; | 
|             grdMain.Columns[HDateCol].HeaderText = "日期"; | 
|             grdMain.Columns[HUnitNumberCol].HeaderText = "单位代码"; | 
|             grdMain.Columns[HUnitNameCol].HeaderText = "单位名称"; | 
|             grdMain.Columns[HQtyCol].HeaderText = "数量"; | 
|             grdMain.Columns[HMinQtyCol].HeaderText = "内箱包装量"; | 
|             grdMain.Columns[HWXQtyCol].HeaderText = "外箱包装量"; | 
|             grdMain.Columns[HBQtyCol].HeaderText = "内箱数"; | 
|             grdMain.Columns[HWBQtyCol].HeaderText = "外箱数"; | 
|             grdMain.Columns[HSeOrderBillNoCol].HeaderText = "销售订单号"; | 
|             grdMain.Columns[HKFDateCol].HeaderText = "生产日期"; | 
|             grdMain.Columns[HKFPeriodCol].HeaderText = "保质期"; | 
|             grdMain.Columns[HKFDQDateCol].HeaderText = "到期日"; | 
|             grdMain.Columns[HwhidCol].HeaderText = "仓库ID"; | 
|             grdMain.Columns[HSPidCol].HeaderText = "仓位ID"; | 
|             //// | 
|             grdMain.Columns[HSnoCol].HeaderText = "序号"; | 
|             //格式化 //隐藏列 | 
|             grdMain.Columns[HModelCol].Visible = false; | 
|             grdMain.Columns[HTagCol].Visible = false; | 
|             grdMain.Columns[HMainIDCol].Visible = false; | 
|             grdMain.Columns[HSubIDCol].Visible = false; | 
|             grdMain.Columns[HBillTypeCol].Visible = false; | 
|             grdMain.Columns[HSupIDCol].Visible = false; | 
|             grdMain.Columns[HMaterIDCol].Visible = false; | 
|           //  grdMain.Columns[HBatchNoCol].Visible = false; | 
|             grdMain.Columns[HUnitIDCol].Visible = false; | 
|             grdMain.Columns[HDateCol].Visible = false; | 
|             grdMain.Columns[HinitQtyCol].Visible = false; | 
|             grdMain.Columns[HwhidCol].Visible = false; | 
|             grdMain.Columns[HSPidCol].Visible = false; | 
|             //grdMain.Columns[HKFDateCol].Visible = false; | 
|             //grdMain.Columns[HKFPeriodCol].Visible = false; | 
|             //设置可编辑列 | 
|             string sAllowCol = HQtyCol.ToString() + | 
|                                 "," + HSupNumberCol.ToString() + | 
|                                 "," + HMaterNumberCol.ToString() + | 
|                                 "," + HUnitNumberCol.ToString() + | 
|                                 "," + HMinQtyCol.ToString() + | 
|                                 "," + HWXQtyCol.ToString(); | 
|             //设置合计列 | 
|             string sTotalCol =  HQtyCol.ToString() ; | 
|             // | 
|             DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol,oSumGrid); | 
|             //---------------------------- | 
|   | 
|             grdSub.ColumnCount = 29;                       //总列数 | 
|             DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name); | 
|             grdSub.Columns[HTMCol].HeaderText = "条码"; | 
|             grdSub.Columns[HSno2Col].HeaderText = "序号"; | 
|             grdSub.Columns[HSupID2Col].HeaderText = "供应商ID"; | 
|             grdSub.Columns[HSupNumber2Col].HeaderText = "供应商代码"; | 
|             grdSub.Columns[HSupName2Col].HeaderText = "供应商名称"; | 
|             grdSub.Columns[HMaterID2Col].HeaderText = "物料ID"; | 
|             grdSub.Columns[HMaterNumber2Col].HeaderText = "物料代码"; | 
|             grdSub.Columns[HMaterName2Col].HeaderText = "物料名称"; | 
|             grdSub.Columns[HMaterModel2Col].HeaderText = "规格型号"; | 
|             grdSub.Columns[HModel2Col].HeaderText = "自定义规格"; | 
|             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[HSourceInterIDCol].HeaderText = "源单主ID"; | 
|             grdSub.Columns[HSourceEntryIDCol].HeaderText = "源单子ID"; | 
|             grdSub.Columns[HSourceBillNoCol].HeaderText = "源单单号"; | 
|             grdSub.Columns[HSourceBillTypeCol].HeaderText = "源单类型"; | 
|             grdSub.Columns[HDateCol2].HeaderText = "日期"; | 
|             grdSub.Columns[HSeOrderBillNo2Col].HeaderText = "销售订单号"; | 
|             grdSub.Columns[HKFDate2Col].HeaderText = "生产日期"; | 
|             grdSub.Columns[HKFPeriod2Col].HeaderText = "保质期"; | 
|             grdSub.Columns[HKFDQDate2Col].HeaderText = "到期日"; | 
|             grdSub.Columns[HwhidCol2].HeaderText = "仓库ID"; | 
|             grdMain.Columns[HSPidCol2].HeaderText = "仓位ID"; | 
|             grdMain.Columns[HMinQtyCol2].HeaderText = "内箱数量"; | 
|   | 
|             //格式化  | 
|             grdSub.Columns[HSupID2Col].Visible = false; | 
|             grdSub.Columns[HMaterID2Col].Visible = false; | 
|             grdSub.Columns[HBatchNo2Col].Visible = false; | 
|             grdSub.Columns[HUnitID2Col].Visible = false; | 
|             grdSub.Columns[HSourceInterIDCol].Visible = false; | 
|             grdSub.Columns[HSourceEntryIDCol].Visible = false; | 
|             grdSub.Columns[HWeiCol].Visible = false; | 
|             grdSub.Columns[HModel2Col].Visible = false; | 
|             grdSub.Columns[HBatchNo2Col].Visible = false; | 
|             grdSub.Columns[HwhidCol2].Visible = false; | 
|             grdMain.Columns[HSPidCol2].Visible = false; | 
|   | 
|             //DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); | 
|             //DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); | 
|   | 
|   | 
|             grdSub2.ColumnCount = 26;                       //总列数 | 
|             DBUtility.Xt_BaseBillFun.initGridFst(grdSub2, this.Name); | 
|             grdSub2.Columns[HTMCol].HeaderText = "条码"; | 
|             grdSub2.Columns[HSno2Col].HeaderText = "序号"; | 
|             grdSub2.Columns[HSupID2Col].HeaderText = "供应商ID"; | 
|             grdSub2.Columns[HSupNumber2Col].HeaderText = "供应商代码"; | 
|             grdSub2.Columns[HSupName2Col].HeaderText = "供应商名称"; | 
|             grdSub2.Columns[HMaterID2Col].HeaderText = "物料ID"; | 
|             grdSub2.Columns[HMaterNumber2Col].HeaderText = "物料代码"; | 
|             grdSub2.Columns[HMaterName2Col].HeaderText = "物料名称"; | 
|             grdSub2.Columns[HMaterModel2Col].HeaderText = "规格型号"; | 
|             grdSub2.Columns[HModel2Col].HeaderText = "自定义规格"; | 
|             grdSub2.Columns[HBatchNo2Col].HeaderText = "批号"; | 
|             grdSub2.Columns[HUnitID2Col].HeaderText = "单位ID"; | 
|             grdSub2.Columns[HUnitNumber2Col].HeaderText = "单位代码"; | 
|             grdSub2.Columns[HUnitName2Col].HeaderText = "单位名称"; | 
|             grdSub2.Columns[HQty2Col].HeaderText = "数量"; | 
|             grdSub2.Columns[HWeiCol].HeaderText = "尾数"; | 
|             grdSub2.Columns[HPrintCol].HeaderText = "打印次数"; | 
|             grdSub2.Columns[HSourceInterIDCol].HeaderText = "源单主ID"; | 
|             grdSub2.Columns[HSourceEntryIDCol].HeaderText = "源单子ID"; | 
|             grdSub2.Columns[HSourceBillNoCol].HeaderText = "源单单号"; | 
|             grdSub2.Columns[HSourceBillTypeCol].HeaderText = "源单类型"; | 
|             grdSub2.Columns[HDateCol2].HeaderText = "日期"; | 
|             grdSub2.Columns[HSeOrderBillNo2Col].HeaderText = "销售订单号"; | 
|             grdSub2.Columns[HKFDate2Col].HeaderText = "生产日期"; | 
|             grdSub2.Columns[HKFPeriod2Col].HeaderText = "保质期"; | 
|             grdSub2.Columns[HKFDQDate2Col].HeaderText = "到期日"; | 
|             //格式化  | 
|             grdSub2.Columns[HSupID2Col].Visible = false; | 
|             grdSub2.Columns[HMaterID2Col].Visible = false; | 
|             grdSub2.Columns[HBatchNo2Col].Visible = false; | 
|             grdSub2.Columns[HUnitID2Col].Visible = false; | 
|             grdSub2.Columns[HSourceInterIDCol].Visible = false; | 
|             grdSub2.Columns[HSourceEntryIDCol].Visible = false; | 
|             grdSub2.Columns[HWeiCol].Visible = false; | 
|             grdSub2.Columns[HModel2Col].Visible = false; | 
|             grdSub2.Columns[HBatchNo2Col].Visible = false; | 
|   | 
|             DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); | 
|             DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); | 
|             DBUtility.Xt_BaseBillFun.GetGrid(grdSub2, this.Name + "grdSub2"); | 
|   | 
|         } | 
|          | 
|         //公式重算 | 
|         private void RowCount(int sRow, int sTag) | 
|         { | 
|             if (sTag == 0) | 
|             { | 
|                 //箱数列=数量/最小包装数 | 
|                 double sMoney = 0; | 
|                 double sMoney2 = 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); | 
|                 } | 
|                 if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HWXQtyCol].Value) == 0) | 
|                 { | 
|                     sMoney2 = 0; | 
|                 } | 
|                 else | 
|                 { | 
|                     sMoney2 = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HWXQtyCol].Value); | 
|                 } | 
|                 sMoney2 = Math.Ceiling(sMoney2); | 
|                 grdMain.Rows[sRow].Cells[HWBQtyCol].Value = sMoney2; | 
|                 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) | 
|         { | 
|             DAL.ClsGy_Process_View oProc = new DAL.ClsGy_Process_View(); | 
|             DAL.ClsK3_Employee_View oEmp = new DAL.ClsK3_Employee_View(); | 
|             DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View(); | 
|             DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View(); | 
|             DAL.ClsGy_Source_View oSource = 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 HMaterNumberCol: | 
|                                 BLL.ClsBaseSelect_K3.SetGridByMater_K3(grdMain, sRow, HMaterIDCol, HMaterNumberCol, HMaterNameCol, HMaterModelCol, HUnitIDCol, HUnitNumberCol, HUnitNameCol); | 
|                                 oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HMaterNumberCol].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; | 
|                                 } | 
|                                 else | 
|                                 { | 
|                                     grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0; | 
|                                     grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = ""; | 
|                                     grdMain.Rows[sRow].Cells[HUnitNameCol].Value = ""; | 
|                                 } | 
|                                 break; | 
|                             case HSupNumberCol: | 
|                                 BLL.ClsBaseSelect_K3.SetGridBySup_K3(grdMain, sRow, HSupIDCol, HSupNumberCol, HSupNameCol); | 
|                                 oEdit.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[sRow].Cells[HSupNumberCol].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[HEmpNameCol].Value = oEmp.oModel.HName; | 
|                             //    } | 
|                             //    else | 
|                             //    { | 
|                             //        grdMain.Rows[sRow].Cells[HWorkerIDCol].Value = 0; | 
|                             //        grdMain.Rows[sRow].Cells[HWorkerNumberCol].Value = ""; | 
|                             //        grdMain.Rows[sRow].Cells[HEmpNameCol].Value = ""; | 
|                             //    } | 
|                             //    break; | 
|                             //case HSourceNumberCol: | 
|                             //    oSource.WherePart = ""; | 
|                             //    if (oSource.RefreshView()) | 
|                             //    { | 
|                             //        grdMain.Rows[sRow].Cells[HSourceIDCol].Value = oSource.oModel.HItemID.ToString(); | 
|                             //        grdMain.Rows[sRow].Cells[HSourceNumberCol].Value = oSource.oModel.HNumber; | 
|                             //        grdMain.Rows[sRow].Cells[HSourceNameCol].Value = oSource.oModel.HName; | 
|                             //    } | 
|                             //    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 = "" ; | 
|                 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_K3_POOrderBillList oCls_S_K3_POOrderBillList = new DAL.Cls_S_K3_POOrderBillList(); | 
|                 if (oCls_S_K3_POOrderBillList.Refresh(sWhere))  //选择原单 | 
|                 { | 
|                     FillSelectData(oCls_S_K3_POOrderBillList.oBillSelectColl); | 
|                 } | 
|             } | 
|             else if (cmbSourceBillType.Text.Trim() == "委外订单")    //幻 | 
|             { | 
|                 string sWhere = ""; | 
|                 DAL.Cls_S_K3_POOrderBillList oCls_S_K3_POOrderBillList = new DAL.Cls_S_K3_POOrderBillList(); | 
|                 if (oCls_S_K3_POOrderBillList.Refresh(sWhere))  //选择原单 | 
|                 { | 
|                     FillSelectData(oCls_S_K3_POOrderBillList.oBillSelectColl); | 
|                 } | 
|             } | 
|             else if (cmbSourceBillType.Text.Trim() == "外购入库单")    //幻 | 
|             { | 
|                 string sWhere = ""; | 
|                 DAL.Cls_S_K3_POStockInBillList oCls_S_K3_POStockInBillList = new DAL.Cls_S_K3_POStockInBillList(); | 
|                 if (oCls_S_K3_POStockInBillList.Refresh(sWhere))  //选择原单 | 
|                 { | 
|                     FillSelectData(oCls_S_K3_POStockInBillList.oBillSelectColl); | 
|                 } | 
|             } | 
|             else if (cmbSourceBillType.Text.Trim() == "即时库存")    //幻 | 
|             { | 
|                 //string sWhere = ""; | 
|                 //DAL.Cls_S_K3_POStockInBillList oCls_S_K3_POStockInBillList = new DAL.Cls_S_K3_POStockInBillList(); | 
|                 //if (oCls_S_K3_POStockInBillList.Refresh(sWhere))  //选择原单 | 
|                 //{ | 
|                 //    FillSelectData(oCls_S_K3_POStockInBillList.oBillSelectColl); | 
|                 //} | 
|   | 
|                 string sWhere = ""; | 
|                 BLL.Cls_S_KF_ICInventoryList_K3 oadd = new BLL.Cls_S_KF_ICInventoryList_K3(); | 
|                 if (oadd.Refresh(sWhere))  //选择原单 | 
|                 { | 
|                     FillSelectData(oadd.oBillSelectColl); | 
|                 } | 
|             } | 
|             else  | 
|             { | 
|   | 
|             } | 
|         } | 
|         private void FillSelectData2(List<DAL.BillSelect2> oList) | 
|         { | 
|             DataSet Ds; | 
|             SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|             oSumGrid.Changelock = true; | 
|             initGrid(); | 
|             int i = -1; | 
|             foreach (DAL.BillSelect2 oSelectRow in oList) | 
|             { | 
|                 i = i + 1; | 
|                 // | 
|   | 
|                 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 + "'"+ " and 生产日期='"+oSelectRow.FKdate+"'"+" and 保质期='"+oSelectRow.FPrid+"'", "h_v_KF_ICInventoryList_K3"); | 
|                     //写入信息 | 
|                     Sub_WriteInForm_ICIN(Ds.Tables[0], i); | 
|                 } | 
|   | 
|             } | 
|             // | 
|             oSumGrid.Changelock = false; | 
|             DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); | 
|         } | 
|         // | 
|         private void FillSelectData(List<DBUtility.BillSelect> 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 == "71") | 
|                 { | 
|                     grdMain.Rows.Add(); | 
|                     grdMain.Rows[i].Cells[HTagCol].Value = "*"; | 
|                     //得到信息                             | 
|                     Ds = oCn.RunProcReturn("select * from h_v_K3_POOrderBillList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_K3_POOrderBillList"); | 
|                     //写入信息 | 
|                     Sub_WriteInForm(Ds.Tables[0], i); | 
|                 } | 
|                 // | 
|                 if (oSelectRow.BillType == "1") | 
|                 { | 
|                     grdMain.Rows.Add(); | 
|                     grdMain.Rows[i].Cells[HTagCol].Value = "*"; | 
|                     //得到信息 | 
|                     Ds = oCn.RunProcReturn("select * from h_v_Kf_POStockInBillList_K3 where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_Kf_POStockInBillList_K3"); | 
|                     //写入信息 | 
|                     Sub_WriteInForm(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[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[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();  //HZxbzlCol | 
|             grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["内箱包装量"].ToString(); | 
|             grdMain.Rows[i].Cells[HWXQtyCol].Value = oTable.Rows[0]["外箱包装量"].ToString(); | 
|            // grdMain.Rows[i].Cells[HModelCol].Value = oTable.Rows[0]["自定义规格"].ToString(); | 
|             grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[0]["批次"].ToString(); | 
|             grdMain.Rows[i].Cells[HKFDateCol].Value = oTable.Rows[0]["生产日期"].ToString(); | 
|             grdMain.Rows[i].Cells[HKFPeriodCol].Value = oTable.Rows[0]["保质期"].ToString(); | 
|             grdMain.Rows[i].Cells[HKFDQDateCol].Value = Convert.ToDateTime(oTable.Rows[0]["生产日期"]).AddDays(Convert.ToDouble(oTable.Rows[0]["保质期"])).ToString("yyyy-MM-dd"); | 
|             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[HSeOrderBillNoCol].Value = oTable.Rows[0]["销售订单号"].ToString(); | 
|             grdMain.Rows[i].Cells[HDateCol].Value = string.Format("{0:yyyyMMdd}", ClsPub.isDate(ClsPub.GetServerDate(0))); | 
|             //-- | 
|             //设置可编辑列 | 
|             string sAllowCol = HQtyCol.ToString() + | 
|                                 "," + HWXQtyCol.ToString()+ | 
|                                 "," + HMinQtyCol.ToString(); | 
|             //设置合计列 | 
|             string sTotalCol = HQtyCol.ToString(); | 
|             // | 
|             DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); | 
|         } | 
|   | 
|         private void Sub_WriteInForm_ICIN(DataTable oTable, int i) | 
|         { | 
|             grdMain.Rows[i].Cells[HTagCol].Value = "*"; | 
|             grdMain.Rows[i].Cells[HQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["数量"]); | 
|             grdMain.Rows[i].Cells[HSupNameCol].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();  //HZxbzlCol | 
|             grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["内箱包装量"].ToString(); | 
|             grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[0]["批次"].ToString(); | 
|             grdMain.Rows[i].Cells[HKFDateCol].Value = oTable.Rows[0]["生产日期"].ToString(); | 
|             grdMain.Rows[i].Cells[HKFPeriodCol].Value = oTable.Rows[0]["保质期"].ToString(); | 
|             grdMain.Rows[i].Cells[HKFDQDateCol].Value = Convert.ToDateTime(oTable.Rows[0]["生产日期"]).AddDays(Convert.ToDouble(oTable.Rows[0]["保质期"])).ToString("yyyy-MM-dd"); | 
|             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[HSeOrderBillNoCol].Value = oTable.Rows[0]["销售订单号"].ToString(); | 
|             grdMain.Rows[i].Cells[HwhidCol].Value = oTable.Rows[0]["hwhid"].ToString(); | 
|             grdMain.Rows[i].Cells[HSPidCol].Value = oTable.Rows[0]["Hspid"].ToString(); | 
|             grdMain.Rows[i].Cells[HDateCol].Value = string.Format("{0:yyyyMMdd}", ClsPub.isDate(ClsPub.GetServerDate(0))); | 
|             //-- | 
|             //设置可编辑列 | 
|             string sAllowCol = HQtyCol.ToString() + | 
|                                 "," + HWXQtyCol.ToString() + | 
|                                 "," + HMinQtyCol.ToString(); | 
|             //设置合计列 | 
|             string sTotalCol = HQtyCol.ToString(); | 
|             // | 
|             DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); | 
|         } | 
|         //网格编辑前判断 | 
|         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; | 
|   | 
|         //预览 | 
|         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) | 
|             { | 
|                 CurRows = grdSub.CurrentRow.Index; | 
|                 Sub_SetReport(oFrm.sOpenTmp); | 
|                 Report.PrintPreview(true); | 
|                 Thread.Sleep(1000);  | 
|             } | 
|         } | 
|   | 
|         private void Sub_SetReport(string sOpenTmp) | 
|         { | 
|             //判断行数 | 
|             // | 
|             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 Sub_SetReport2(string sOpenTmp) | 
|         { | 
|             //判断行数 | 
|             // | 
|             Report = new GridppReport(); | 
|             Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here . | 
|             Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord2); | 
|             Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable2); | 
|         } | 
|         //填入单据表头信息 | 
|         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[HSupName2Col].Value); | 
|                 Report.FieldByName("条码").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HTMCol].Value); | 
|                 Report.FieldByName("数量").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HQty2Col].Value); | 
|                 DateTime Date =Convert.ToDateTime(grdSub.Rows[CurRows].Cells[HKFDate2Col].Value); | 
|                 Report.FieldByName("生产日期").AsString = ClsPub.isStrNull(Date.ToString("d")); | 
|                 Report.FieldByName("批号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HBatchNo2Col].Value); | 
|                 Report.FieldByName("单位").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HUnitName2Col].Value);// | 
|                 Report.FieldByName("收料单号").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); | 
|                 Report.FieldByName("到期日期").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HKFDQDate2Col].Value); | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 MessageBox.Show("打印失败!表头:" + e.Message); | 
|             } | 
|         } | 
|         private void ReportBeforePostRecord2()//  | 
|         { | 
|             try | 
|             { | 
|                 Report.FieldByName("物料编码").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HMaterNumber2Col].Value); | 
|                 Report.FieldByName("物料名称").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HMaterName2Col].Value); | 
|                 Report.FieldByName("供应商").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HSupName2Col].Value); | 
|                 Report.FieldByName("条码").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HTMCol].Value); | 
|                 Report.FieldByName("数量").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HQty2Col].Value); | 
|                 DateTime Date = Convert.ToDateTime(grdSub2.Rows[CurRows].Cells[HKFDate2Col].Value); | 
|                 Report.FieldByName("生产日期").AsString = ClsPub.isStrNull(Date.ToString("d")); | 
|                 Report.FieldByName("批号").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HBatchNo2Col].Value); | 
|                 Report.FieldByName("单位").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HUnitName2Col].Value);// | 
|                 Report.FieldByName("收料单号").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HSourceBillNoCol].Value); | 
|                 Report.FieldByName("到期日期").AsString = ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HKFDQDate2Col].Value); | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 MessageBox.Show("打印失败!表头:" + e.Message); | 
|             } | 
|         } | 
|         private void ReportFetchRecordByDataTable() | 
|         { | 
|             try | 
|             { | 
|                 DataTable ds = new DataTable(); | 
|                 BLL.Utility.FillRecordToReport_FstRow(Report, grdSub, ds, HTMCol); | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 MessageBox.Show("打印失败!表体:" + e.Message); | 
|             } | 
|         } | 
|         private void ReportFetchRecordByDataTable2() | 
|         { | 
|             try | 
|             { | 
|                 DataTable ds = new DataTable(); | 
|                 BLL.Utility.FillRecordToReport_FstRow(Report, grdSub2, ds, HTMCol); | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 MessageBox.Show("打印失败!表体:" + e.Message); | 
|             } | 
|         } | 
|         private void dy_Click(object sender, EventArgs e) | 
|         { | 
|             //选择打印模板 | 
|             BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp(); | 
|             DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl(); | 
|             oFrm.sBillName = ModName; | 
|             oFrm.sBillModel = ModCaption; | 
|             oFrm.ShowDialog(); | 
|             if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK) | 
|             { | 
|                 // | 
|                 if (tabControl1.SelectedIndex==1) | 
|                 { | 
|                     for (int i = 0; i <= grdSub.RowCount - 1; i++) | 
|                     { | 
|                         CurRows = grdSub.Rows[i].Index; | 
|                         Sub_SetReport(oFrm.sOpenTmp); | 
|                         Report.Print(false); | 
|                         oBar.Set_PrintQty(DBUtility.ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HTMCol].Value)); | 
|                         Thread.Sleep(1000); | 
|                     } | 
|                 } | 
|                 if (tabControl1.SelectedIndex == 2) | 
|                 { | 
|                     // | 
|                         for (int i = 0; i <= grdSub2.RowCount - 1; i++) | 
|                         { | 
|                             if (grdSub2.Rows[CurRows].Cells[HTMCol].Value != null) | 
|                             { | 
|                                 CurRows = grdSub2.Rows[i].Index; | 
|                                 Sub_SetReport2(oFrm.sOpenTmp); | 
|                                 Report.Print(false); | 
|                                 oBar.Set_PrintQty(DBUtility.ClsPub.isStrNull(grdSub2.Rows[CurRows].Cells[HTMCol].Value)); | 
|                                 Thread.Sleep(1000); | 
|                             } | 
|                             else | 
|                             { | 
|                                 return; | 
|                             } | 
|                         } | 
|                 } | 
|             } | 
|   | 
|         } | 
|   | 
|         private void set_Click(object sender, EventArgs e) | 
|         {  //  | 
|             BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp(); | 
|             oFrm.sBillName = ModName; | 
|             oFrm.sBillModel = ModCaption; | 
|             oFrm.ShowDialog(); | 
|         } | 
|   | 
|         #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 textBox2_KeyDown(object sender, KeyEventArgs e) | 
|         { | 
|             if (e.KeyCode == Keys.Enter) | 
|             { | 
|                 FillSelectData2(); | 
|             } | 
|         } | 
|   | 
|         private void FillSelectData2() | 
|         { | 
|             DataSet Ds; | 
|             SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|       | 
|             initGrid(); | 
|             int i = -1; | 
|             i = i + 1; | 
|   | 
|             // | 
|             if (cmbSourceBillType.Text == "外购入库单") | 
|             {  | 
|                 //得到信息 | 
|                 //Ds = oCn.RunProcReturn("select * from h_v_Kf_POStockInBillList_K3 where 单据号=" + textBox2.Text +"and, "h_v_Kf_POStockInBillList_K3"); | 
|                 Ds = oCn.RunProcReturn("select * from h_v_Kf_POStockInBillList_K3 where 单据号='" + textBox2.Text + "'", "h_v_K3_POOrderBillList"); | 
|                 for (int j = 0; j < Ds.Tables[0].Rows.Count; j++) | 
|                 { | 
|                     grdMain.Rows.Add();  | 
|                     //写入信息 | 
|                     Sub_WriteInForm(Ds.Tables[0], j); | 
|                 } | 
|   | 
|   | 
|             } | 
|             // | 
|             //oSumGrid.Changelock = false; | 
|             //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); | 
|         } | 
|   | 
|   | 
|         //选择 职员按钮 | 
|         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 = ""; | 
|             } | 
|             //BLL.ClsBaseSelect_K3.SetTextByEmp_K3(txtHEmpID); | 
|         } | 
|   | 
|         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) | 
|         { | 
|             //string sWhere = ""; | 
|             //BLL.Cls_S_KF_ICInventoryList_K3 oadd = new BLL.Cls_S_KF_ICInventoryList_K3(); | 
|             //if (oadd.Refresh(sWhere))  //选择原单 | 
|             //{ | 
|             //    FillSelectData(oadd.oBillSelectColl); | 
|             //} | 
|             string sWhere = ""; | 
|             DAL.Cls_S_KF_ICInventoryList_K3 oadd = new DAL.Cls_S_KF_ICInventoryList_K3(); | 
|             if (oadd.Refresh(sWhere))  //选择原单 | 
|             { | 
|                // FillSelectData(oadd.oBillSelectColl); | 
|                 FillSelectData2(oadd.oBillSelectColl); | 
|   | 
|             } | 
|         } | 
|   | 
|         private void toolStripButton1_Click(object sender, EventArgs e) | 
|         { | 
|             if (grdMain.Rows[0].Cells[HSubIDCol].Value == null)//HSubIDCol | 
|             { | 
|                 this.Sub_SaveBill2(); | 
|             } | 
|             else | 
|             { | 
|                 MessageBox.Show("只能进行期初库存条码生成!"); | 
|             } | 
|         } | 
|   | 
|     } | 
| } |