using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using gregn6Lib; using Pub_Class; using System.Threading; namespace WarM { public partial class CLD_ICMOList : Form { public CLD_ICMOList() { InitializeComponent(); } //定义 public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HMainIDCol = 2; public const Int16 HSubIDCol = 3; public const Int16 HBillNoCol = 4; public const Int16 HBillTypeCol = 5; public const Int16 HMaterIDCol = 6; public const Int16 HMaterNumberCol = 7; public const Int16 HMaterNameCol = 8; public const Int16 HMaterModelCol = 9; public const Int16 HBatchNoCol = 10; public const Int16 HUnitIDCol = 11; public const Int16 HUnitNumberCol = 12; public const Int16 HUnitNameCol = 13; public const Int16 HQtyCol = 14; public const Int16 HMinQtyCol = 15; public const Int16 HBQtyCol = 16; public Int16 HSno2Col = 0; public Int16 HTMCol = 1; public Int16 HMaterID2Col = 2; public Int16 HMaterNumber2Col = 3; public Int16 HMaterName2Col = 4; public Int16 HMaterModel2Col = 5; public Int16 HBatchNo2Col = 6; public Int16 HLSH2Col = 7; public Int16 HUnitID2Col = 8; public Int16 HUnitNumber2Col = 9; public Int16 HUnitName2Col = 10; public Int16 HQty2Col = 11; public Int16 HWeiCol = 12; public Int16 HPrintCol = 13; public Int16 HSourceInterIDCol = 14; public Int16 HSourceEntryIDCol = 15; public Int16 HSourceBillNoCol = 16; public Int16 HSourceBillTypeCol = 17; // public string ModName = "851"; public string ModCaption = "CLD自制件条码"; public bool BillChange; // public int selectRow = 0; public DBUtility.ClsPub.Enum_BillStatus BillStatus; public Int64 KeyID; public bool grdStatus; //public DAL.ClsCLD_ICMOList BillNew =new DAL.ClsCLD_ICMOList(); //public DAL.ClsCLD_ICMOList BillOld = new DAL.ClsCLD_ICMOList(); ClsGridViewSum oSumGrid = new ClsGridViewSum(); //------------------------------------------------------------------------- #region 固定代码 //清空界面 public void Sub_ClearBill() { DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp); // txtHMaker.Text = ClsPub.CurUserName; txtHMakeDate.Text = ""; txtHChecker.Text = ""; txtHCheckDate.Text = ""; txtHCloseMan.Text = ""; txtHCloseDate.Text = ""; txtHDeleteMan.Text = ""; txtHDeleteDate.Text = ""; txtHUpDater.Text = ""; txtHUpDateDate.Text = ""; 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.ClsCLD_ICMOList(); // this.Sub_Next(); //显示下一张单据 // if (BillOld.omodel.HInterID == 0)//若找不到下一张,则显示上一张 // { // this.Sub_Prev(); // } // if (BillOld.omodel.HInterID == 0)//若找不到上一张,清空 // { // this.Sub_ClearBill(); // } // BillStatus =DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; // this.Sub_OperStatus(); //} } private void bclk_Click(object sender, EventArgs e) { //保存列宽 DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub"); } //增行按钮 private void AddRow_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.AddRow(oSumGrid); } //删行按纽 private void DelRow_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.DelRow(oSumGrid); } private void mrlk_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub"); } //离开单元格 private void grdMain_LeaveCell(object sender, EventArgs e) { oSumGrid.LeaveCell(); } //网格单元格变化事件 private void grdMain_RowColChange(object sender, EventArgs e) { // if (!grdStatus) { return; } DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // //if (oSumGrid.Changelock) // return; //if(oSumGrid.EditStatus) //{ if (!CheckGridRow(oSumGrid.OldCell.Row)) return; //} } //放弃 编辑 private void Sub_AbandonBill() { //if (BillStatus ==DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew || BillStatus ==DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify) //{ // if (MessageBox.Show("单据尚未保存,是否放弃?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) // { // //显示第一张单据 // this.Sub_First(); // } //} MessageBox.Show("条码打印完毕!"); } private void CLD_ICMOList_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 CLD_ICMOList_Load(object sender, EventArgs e) { //打印初始化 dtpHDate.Value = DateTime.Today; oSumGrid.NoCol = HSnoCol; oSumGrid.ogrdMain = grdMain; oSumGrid.oGridsum = grdSum; CheckUseOrgID(); this.Text = ModCaption; this.lblCaption.Text = ModCaption; } //首张 private void Sub_First() { //BillStatus =DBUtility.ClsPub.Enum_BillStatus.BillStatus_View; //BillOld = new DAL.ClsCLD_ICMOList(); //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.ClsCLD_ICMOList(); //if (BillOld.GetLastBill(ref ClsPub.sExeReturnInfo)) //{ // this.Sub_ShowBill(); //} } //审核单据 private void Sub_CheckBill() { //if (BillOld.CheckBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHChecker.Text = ClsPub.CurUserName; // txtHCheckDate.Text = BillOld.omodel.HCheckDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("审核失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反审单据 private void Sub_AbandonCheck() { //if (BillOld.AbandonCheck(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHChecker.Text = ""; // txtHCheckDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("反审核失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //关闭单据 private void Sub_CloseBill() { //if (BillOld.CloseBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHCloseMan.Text = ClsPub.CurUserName; // txtHCloseDate.Text = BillOld.omodel.HCloseDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("关闭失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反关闭单据 private void Sub_Cancel() { //if (BillOld.CancelClose(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // txtHCloseMan.Text = ""; // txtHCloseDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("恢复失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //作废单据 private void Sub_Cancelltion() { //if (BillOld.Cancelltion(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // this.txtHDeleteMan.Text = ClsPub.CurUserName; // this.txtHDeleteDate.Text = BillOld.omodel.HDeleteDate; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("作废失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //反作废 private void Sub_AbandonCancelltion() { //if (BillOld.AbandonCancelltion(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == true) //{ // BillChange = true; // this.txtHDeleteMan.Text = ""; // this.txtHDeleteDate.Text = ""; // this.Sub_OperStatus();//刷新TOOL按钮 //} //else //{ // MessageBox.Show("作废失败!原因:" + ClsPub.sExeReturnInfo, "提示"); //} } //新增按纽 private void xz_Click(object sender, EventArgs e) { this.Sub_AddBill(); } //修改按纽 private void xg_Click(object sender, EventArgs e) { this.Sub_EditBill(); } //删除按钮 private void sc_Click(object sender, EventArgs e) { this.Sub_DeleteBill(); } //保存按钮 private void bc_Click(object sender, EventArgs e) { this.Sub_SaveBill(); } //放弃按钮 private void fq_Click(object sender, EventArgs e) { 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 CLD_ICMOList_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 CLD_ICMOList_FormClosing(object sender, FormClosingEventArgs e) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } //新增单据 private void Sub_AddBill() { //this.BillNew = new DAL.ClsCLD_ICMOList(); //this.BillOld = new DAL.ClsCLD_ICMOList(); 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.ClsCLD_ICMOListSub 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() { SaveBarCodeBySingle(); //SaveBarCodeByBatchNo(); return true; } //生成条码(批次) private void SaveBarCodeByBatchNo() { grdSub.Rows.Clear(); int LSHlen = 4; //流水号长度 int SumLen = 10; //总长度 string TM = ""; //条码 string HNumber = ""; //物料代码 double HQty = 0; //数量 int HBQty = 0; //箱数量 int HMinQty = 0; //每箱数量 int LSH = 0; //流水号 string LSH2 = ""; //流水号转换成字符 string sYear = ""; //年 string sPeriod = ""; //月 string sHSourceBillNo = ""; //源单单号 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(".", ""); if (cmbHBarCodeType.Text == "箱号条码") { HMinQty = ClsPub.isInt(grdMain.Rows[j].Cells[HMinQtyCol].Value); HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value) ; } else { HMinQty = ClsPub.isInt(grdMain.Rows[j].Cells[HMinQtyCol].Value); HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value ); } //sHSourceBillNo = grdSub.Rows[i].Cells[HSourceBillNoCol].Value; for (int i = k; i < HBQty; i++) { //oCn.RunProc("exec setLSH '" + DateTime.Today + "'"); //LSH = LSH + 1; //LSH2 = LSH.ToString(); //while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0 //{ // LSH2 = "0" + LSH2; //} sYear = DateTime.Today.Year.ToString().Substring(2, 2); sPeriod = "0" + DateTime.Today.Month.ToString(); sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2); //================================== TM = sHSourceBillNo + ";" + HNumber + ";" + sYear + sPeriod + HMinQty; //while (TM.Length < SumLen) //如果条码小于12位数前面补0 //{ // TM = "0" + TM; //} //if (cmbHBarCodeType.Text == "箱号条码") //{ // TM = "B" + TM; //} //--------------------------- if (i + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[i].Cells[HTMCol].Value = TM; grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty; grdSub.Rows[i].Cells[HBatchNo2Col].Value = grdMain.Rows[j].Cells[HBatchNoCol].Value; grdSub.Rows[i].Cells[HSourceInterIDCol].Value = grdMain.Rows[j].Cells[HMainIDCol].Value; grdSub.Rows[i].Cells[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 = ""; string HBarCodeType = ""; Int64 HMaterID = 0; Int64 HUnitID = 0; double HQty2 = 0; string HBatchNo = ""; Int64 HSupID = 0; Int64 HGroupID = 0; int HPrintQty = 0; Int64 HSourceInterID = 0; Int64 HSourceEntryID = 0; string HSourceBillNo = ""; string HSourceBillType = ""; try { oCn.BeginTran(); for (int i = 0; i < grdSub.Rows.Count; i++) { if (ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value) != 0) { HBarCode = grdSub.Rows[i].Cells[HTMCol].Value.ToString(); HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text); HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value); HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value); HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value); HBatchNo = grdSub.Rows[i].Cells[HBatchNo2Col].Value.ToString(); HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterIDCol].Value); HSourceBillNo = grdSub.Rows[i].Cells[HSourceBillNoCol].Value.ToString(); HSourceBillType = grdSub.Rows[i].Cells[HSourceBillTypeCol].Value.ToString(); oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType " + ") values (" + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HBatchNo + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "')"); //oCn.RunProc("exec setLSH '" + DateTime.Today + "'"); } } oCn.Commit(); MessageBox.Show("条码生成完毕!"); } catch (Exception e) { oCn.RollBack(); MessageBox.Show("条码生成失败!" + e.Message); } } //生成条码(单品) private void SaveBarCodeBySingle() { //lblCaption.Focus(); //grdSub.Rows.Clear(); //int LSHlen = 4; //流水号长度 //int SumLen = 10; //总长度 //string TM = ""; //条码 //string HNumber = ""; //物料代码 //double HQty = 0; //数量 //int LSH = 0; //流水号 //string LSH2 = ""; //流水号转换成字符 //string sYear = ""; //年 //string sPeriod = ""; //月 //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(".", ""); // if (cmbHBarCodeType.Text == "箱号条码") // { // HQty = Math.Ceiling(HQty + ClsPub.isDoule(grdMain.Rows[j].Cells[HBQtyCol].Value)); // } // else // { // HQty = Math.Ceiling(HQty + ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value)); // } // for (int i = k; i < HQty; i++) // { // LSH = LSH + 1; // LSH2 = LSH.ToString(); // while (LSH2.Length < LSHlen) //如果流水号小于6位数前面补0 // { // LSH2 = "0" + LSH2; // } // sYear = DateTime.Today.Year.ToString().Substring(2, 2); // sPeriod = "0" + DateTime.Today.Month.ToString(); // sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2); // //================================== // TM = HNumber + sYear + sPeriod + LSH2; // while (TM.Length < SumLen) //如果条码小于12位数前面补0 // { // TM = "0" + TM; // } // if (cmbHBarCodeType.Text == "箱号条码") // { // TM = "B" + TM; // } // if (i + 1 > grdSub.Rows.Count) // { // grdSub.RowCount = grdSub.RowCount + 1; // } // grdSub.Rows[i].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); // grdSub.Rows[i].Cells[HTMCol].Value = TM; // grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value; // grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value; // grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value; // grdSub.Rows[i].Cells[HMaterModel2Col].Value = grdMain.Rows[j].Cells[HMaterModelCol].Value; // grdSub.Rows[i].Cells[HUnitID2Col].Value = grdMain.Rows[j].Cells[HUnitIDCol].Value; // grdSub.Rows[i].Cells[HUnitNumber2Col].Value = grdMain.Rows[j].Cells[HUnitNumberCol].Value; // grdSub.Rows[i].Cells[HUnitName2Col].Value = grdMain.Rows[j].Cells[HUnitNameCol].Value; // grdSub.Rows[i].Cells[HQty2Col].Value = 1; // 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[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 = ""; //string HBarCodeType = ""; //Int64 HMaterID = 0; //Int64 HUnitID = 0; //double HQty2 = 0; //string HBatchNo = ""; //Int64 HSupID = 0; //Int64 HGroupID = 0; //int HPrintQty = 0; //Int64 HSourceInterID = 0; //Int64 HSourceEntryID = 0; //string HSourceBillNo = ""; //string HSourceBillType = ""; //try //{ // oCn.BeginTran(); // for (int i = 0; i < grdSub.Rows.Count; i++) // { // if (ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value) != 0) // { // HBarCode = grdSub.Rows[i].Cells[HTMCol].Value.ToString(); // HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text); // HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value); // HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value); // HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value); // HBatchNo = grdSub.Rows[i].Cells[HBatchNo2Col].Value.ToString(); // HSourceInterID = ClsPub.isLong(grdSub.Rows[i].Cells[HSourceInterIDCol].Value); // HSourceBillNo = grdSub.Rows[i].Cells[HSourceBillNoCol].Value.ToString(); // HSourceBillType = grdSub.Rows[i].Cells[HSourceBillTypeCol].Value.ToString(); // oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + // ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty" + // ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType " + // ") values (" // + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID + "," + HUnitID + "," + HQty2 // + ",'" + HBatchNo + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty // + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "')"); // oCn.RunProc("exec setLSH '" + DateTime.Today + "'"); // } // } // oCn.Commit(); // MessageBox.Show("条码生成完毕!"); //} //catch (Exception e) //{ // oCn.RollBack(); // MessageBox.Show("条码生成失败!" + e.Message); //} lblCaption.Focus(); grdSub.Rows.Clear(); int k = 0; DataSet Ds; 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); string sHSourceBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].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; int HBQty = 0; int LSH = 0; string LSH2 = ""; string sDate = ""; //日期 string sYear = ""; //年 string sPeriod = ""; //月 string sDay = ""; //日 string sBatchNo = ""; string sNumber = ""; //物料代码+批次 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); sBatchNo = sYear + sPeriod + sDay; HNumber = grdMain.Rows[j].Cells[HMaterNumberCol].Value.ToString(); sNumber = sBatchNo + HNumber; Ds = oCn.RunProcReturn("exec GetLSH '" + sNumber + "'", "GetLSH"); LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1; HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value); HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value); HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value); for (int i = 0; i < HBQty; i++) { //流水号存档 oCn.RunProc("exec setLSH '" + sNumber+"'"); // if (HSumQty - HMinQty > 0) { WeiShu = ""; HSumQty = HSumQty - HMinQty; } else { if (HSumQty == HMinQty) { WeiShu = ""; } else { WeiShu = "尾数"; } HMinQty = HSumQty; } // LSH2 = DBUtility.ClsPub.isStrNull(LSH + i); while (LSH2.Length < 4) { LSH2 = "0" + LSH2; } // if (cmbHBarCodeType.Text == "批次码") { TM = sHSourceBillNo + ";" + HNumber + ";" + sBatchNo + ";" + HMinQty; } else if (cmbHBarCodeType.Text == "唯一码") { TM = sHSourceBillNo + ";" + HNumber + ";" + sBatchNo + ";" + LSH2 + ";" + HMinQty; } else { TM = sHSourceBillNo + ";" + HNumber + ";" + sBatchNo + ";" + HMinQty; } // if (k + 1 > grdSub.Rows.Count) { grdSub.RowCount = grdSub.RowCount + 1; } grdSub.Rows[k].Cells[HSno2Col].Value = ClsPub.isStrNull(i + 1); grdSub.Rows[k].Cells[HTMCol].Value = TM; 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[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 = HMinQty; //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 =sBatchNo; grdSub.Rows[k].Cells[HLSH2Col].Value = LSH2; 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; k = k + 1; } } } string HWei = ""; //尾数 string HLSH2 = ""; //托号 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 HBarCodeType = ""; Int64 HLSHSUM = 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); 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); HLSH2 = ClsPub.isStrNull(grdSub.Rows[i].Cells[HLSH2Col].Value); HLSHSUM = ClsPub.isLong(grdMain.Rows[0].Cells[HBQtyCol].Value); HBarCodeType = cmbHBarCodeType.Text; oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HMaterID,HUnitID,HQty" + ",HBatchNo,HSupID,HGroupID,HDeptID,HMaker,HMakeDate,HPrintQty,HBarCodeType" + ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty,HLSH,HLSHSUM " + ") values (" + "'" + HBarCode + "'," + HMaterID + "," + HUnitID + "," + HQty2 + ",'" + HBatchNo + "'," + HSupID + "," + HGroupID + "," + HDeptID + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty + ",'" + HBarCodeType+"'" + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "','" + HLSH2 + "','" + HLSHSUM + "')"); } } oCn.Commit(); MessageBox.Show("条码生成完毕!"); tabControl1.SelectedIndex = 1; } catch (Exception e) { oCn.RollBack(); MessageBox.Show("条码生成失败!" + e.Message); } } #endregion #region 窗体处理方法 //初始化GRID private void initGrid() { // grdMain.ColumnCount = 17; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name); grdMain.Columns[HMainIDCol].HeaderText = "收料通知单主ID"; grdMain.Columns[HSubIDCol].HeaderText = "收料通知单子ID"; grdMain.Columns[HBillNoCol].HeaderText = "收料通知单号"; grdMain.Columns[HBillTypeCol].HeaderText = "单据类型"; grdMain.Columns[HMaterIDCol].HeaderText = "物料ID"; grdMain.Columns[HMaterNumberCol].HeaderText = "物料代码"; grdMain.Columns[HMaterNameCol].HeaderText = "物料名称"; grdMain.Columns[HMaterModelCol].HeaderText = "规格型号"; grdMain.Columns[HBatchNoCol].HeaderText = "批号"; grdMain.Columns[HUnitIDCol].HeaderText = "单位ID"; grdMain.Columns[HUnitNumberCol].HeaderText = "单位代码"; grdMain.Columns[HUnitNameCol].HeaderText = "单位名称"; grdMain.Columns[HQtyCol].HeaderText = "数量"; grdMain.Columns[HMinQtyCol].HeaderText = "最小包装数"; grdMain.Columns[HBQtyCol].HeaderText = "箱数"; //// grdMain.Columns[HSnoCol].HeaderText = "序号"; //格式化 grdMain.Columns[HTagCol].Visible = false; //隐藏列 grdMain.Columns[HMaterIDCol].Visible = false; grdMain.Columns[HUnitIDCol].Visible = false; grdMain.Columns[HMainIDCol].Visible = false; grdMain.Columns[HSubIDCol].Visible = false; grdMain.Columns[HBillTypeCol].Visible = false; grdMain.Columns[HBatchNoCol].Visible = false; grdMain.Columns[HUnitIDCol].Visible = false; grdMain.Columns[HUnitNumberCol].Visible = false; //设置可编辑列 string sAllowCol = HQtyCol.ToString()+ "," + HMaterNumberCol.ToString() + "," + HMinQtyCol.ToString() + "," + HBQtyCol.ToString(); //设置合计列 string sTotalCol = HQtyCol.ToString() + "," + HMinQtyCol.ToString() + "," + HBQtyCol.ToString(); // DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol,oSumGrid); //---------------------------- grdSub.ColumnCount = 18; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name); grdSub.Columns[HTMCol].HeaderText = "条码"; grdSub.Columns[HSno2Col].HeaderText = "序号"; grdSub.Columns[HMaterID2Col].HeaderText = "物料ID"; grdSub.Columns[HMaterNumber2Col].HeaderText = "物料代码"; grdSub.Columns[HMaterName2Col].HeaderText = "物料名称"; grdSub.Columns[HMaterModel2Col].HeaderText = "规格型号"; grdSub.Columns[HBatchNo2Col].HeaderText = "批号"; grdSub.Columns[HLSH2Col].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[HMaterID2Col].Visible = false; //grdSub.Columns[HBatchNo2Col].Visible = false; grdSub.Columns[HUnitID2Col].Visible = false; grdSub.Columns[HSourceInterIDCol].Visible = false; grdSub.Columns[HSourceEntryIDCol].Visible = false; DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); } //公式重算 private void RowCount(int sRow, int sTag) { if (sTag == 0) { //箱数列=数量/最小包装数 double sMoney = 0; if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value) == 0) { sMoney=0; } else { sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value); } sMoney = Math.Ceiling(sMoney); grdMain.Rows[sRow].Cells[HBQtyCol].Value = sMoney; } else { } } //选择 部门按钮 private void cmdHDeptID_Click(object sender, EventArgs e) { //ClsK3_DepartmentHlp oDept = new ClsK3_DepartmentHlp(); //oDept.WherePart = txtHDeptID.Text.Trim(); //if (oDept.Refresh()) //{ // txtHDeptID.Text = oDept.HName; // txtHDeptID.Tag = oDept.HItemID; //} //else //{ // txtHDeptID.Text = ""; //} } private void txtHDeptID_TextChanged(object sender, EventArgs e) { if (txtHDeptID.Text.Length == 0) { txtHDeptID.Tag = "0"; } } //核对选择的内容 public bool CheckGridCell(Cell oCell) { int Row; int Col; Row = oCell.Row; Col = oCell.Col; //if (ClsPub.isStrNull(grdMain.get_TextMatrix(Row, HTagCol)) != "*") //{ // return true; //} //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone; //判断选中列 if (Col == 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.ClsCLD_Process_View oProc = new DAL.ClsCLD_Process_View(); DAL.ClsCLD_Employee_View oEmp = new DAL.ClsCLD_Employee_View(); DAL.ClsCLD_Material_View oMater = new DAL.ClsCLD_Material_View(); DAL.ClsCLD_Unit_View oUnit = new DAL.ClsCLD_Unit_View(); DAL.ClsCLD_Source_View oSource = new DAL.ClsCLD_Source_View(); DAL.ClsCLD_ORGANIZATIONS_View oOrg = new DAL.ClsCLD_ORGANIZATIONS_View(); if (!grdStatus) { return; } //if (oSumGrid.FindAllowEditCol(sCol)) //{ oSumGrid.EditStatus = true; //} //else //{ // return; //} switch (sKeyCode) { case 118: //F7 { switch (sCol) { case HMaterNumberCol: oOrg.GetInfoByName(cmbHOrg.Text); oMater.WherePart = ""; if (oMater.RefreshView(" and HUSEORGID =" + oOrg.omodel.HItemID)) { grdMain.Rows[sRow].Cells[HMaterIDCol].Value = oMater.omodel.HItemID.ToString(); grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = oMater.omodel.HNumber; grdMain.Rows[sRow].Cells[HMaterNameCol].Value = oMater.omodel.HName; grdMain.Rows[sRow].Cells[HMaterModelCol].Value = oMater.omodel.HModel; grdMain.Rows[sRow].Cells[HUnitIDCol].Value = oMater.omodel.HUnitID.ToString(); grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = oMater.omodel.HUnitNumber; grdMain.Rows[sRow].Cells[HUnitNameCol].Value = oMater.omodel.HUnitName; } else { grdMain.Rows[sRow].Cells[HMaterIDCol].Value = 0; grdMain.Rows[sRow].Cells[HMaterNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HMaterNameCol].Value = ""; grdMain.Rows[sRow].Cells[HMaterModelCol].Value = ""; grdMain.Rows[sRow].Cells[HUnitIDCol].Value = 0; grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = ""; grdMain.Rows[sRow].Cells[HUnitNameCol].Value = ""; } 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_CLD_ICMOList oCLD_ICMOList = new DAL.Cls_S_CLD_ICMOList(); if (oCLD_ICMOList.Refresh(sWhere)) //选择原单 { FillSelectData(oCLD_ICMOList.oBillSelectColl); } } else { } } // private void FillSelectData(List oList) { DataSet Ds; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); oSumGrid.Changelock = true; initGrid(); int i = -1; foreach (DBUtility.BillSelect oSelectRow in oList) { i = i + 1; //生产任务单 if (oSelectRow.BillType == "85") { grdMain.Rows.Add(); grdMain.Rows[i].Cells[HTagCol].Value = "*"; //得到信息 Ds = oCn.RunProcReturn("select * from h_v_CLD_ICMOList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_CLD_ICMOList"); //写入信息 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[HSubIDCol].Value = oTable.Rows[0]["HSubID"].ToString(); grdMain.Rows[i].Cells[HMainIDCol].Value = oTable.Rows[0]["hmainid"].ToString(); grdMain.Rows[i].Cells[HBillNoCol].Value = oTable.Rows[0]["任务单号"].ToString(); grdMain.Rows[i].Cells[HBillTypeCol].Value = oTable.Rows[0]["HBillType"].ToString(); grdMain.Rows[i].Cells[HMaterIDCol].Value = oTable.Rows[0]["HMaterID"].ToString(); grdMain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[0]["物料代码"].ToString(); grdMain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[0]["物料"].ToString(); grdMain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[0]["规格型号"].ToString(); grdMain.Rows[i].Cells[HBatchNoCol].Value = oTable.Rows[0]["批号"].ToString(); grdMain.Rows[i].Cells[HUnitIDCol].Value = oTable.Rows[0]["HUnitID"].ToString(); grdMain.Rows[i].Cells[HUnitNumberCol].Value = oTable.Rows[0]["计量单位代码"].ToString(); grdMain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[0]["计量单位"].ToString(); //-- } private void cmdHGroupID_Click(object sender, EventArgs e) { DAL.ClsCLD_Group_View oGroup = new DAL.ClsCLD_Group_View(); if (oGroup.RefreshView()) { this.txtHGroupID.Text = oGroup.oModel.HName; this.txtHGroupID.Tag = oGroup.oModel.HItemID.ToString(); } else { this.txtHGroupID.Text = ""; } } private void cmdHDeptID_Click_1(object sender, EventArgs e) { DAL.ClsCLD_Department_View oDept = new DAL.ClsCLD_Department_View(); if (oDept.RefreshView()) { this.txtHDeptID.Text = oDept.oModel.HName; this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString(); } else { this.txtHDeptID.Text = ""; } } private void cmdHEmpID_Click(object sender, EventArgs e) { DAL.ClsCLD_Employee_View oEmp = new DAL.ClsCLD_Employee_View(); if (oEmp.RefreshView()) { this.txtHEmpID.Text = oEmp.oModel.HName; this.txtHEmpID.Tag = oEmp.oModel.HItemID.ToString(); } else { this.txtHEmpID.Text = ""; } } //网格编辑前判断 private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { int i = grdMain.CurrentCell.ColumnIndex; if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid,i)) { e.Cancel = true; } } //网格编辑后处理 private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); if (e.ColumnIndex == HMinQtyCol) { RowCount(e.RowIndex, 0); // } else if (e.ColumnIndex == HQtyCol) { RowCount(e.RowIndex, 0); // } // if (this.EditingControl != null) //释放事件 { EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown); this.EditingControl = null; } } DataGridViewTextBoxEditingControl EditingControl; private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e) { // if (!grdStatus) { return; } DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // //if (oSumGrid.Changelock) // return; //if(oSumGrid.EditStatus) //{ if (!CheckGridRow(oSumGrid.OldCell.Row)) return; //} } private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (grdMain.CurrentCell != null) { if (e.Control is DataGridViewTextBoxEditingControl) { this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control; //增加委托处理 this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown); } } } private void EditingControl_KeyDown(object sender, KeyEventArgs e) { //业务处理 Sub_GridKey(e.KeyValue, grdMain.CurrentRow.Index, grdMain.CurrentCell.ColumnIndex, EditingControl); } private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } private void grdMain_Scroll(object sender, ScrollEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); oSumGrid.DisplayCurRow(); } #endregion #region //打印设置 GridppReport Report; //预览 int CurRows = 0; private void yl_Click(object sender, EventArgs e) { //选择打印模板 BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp(); oFrm.sBillName = ModName; oFrm.sBillModel = ModCaption; oFrm.ShowDialog(); if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK) { // selectRow = grdSub.CurrentRow.Index; Sub_SetReport(oFrm.sOpenTmp); Report.PrintPreview(true); } } private void dy_Click(object sender, EventArgs e) { selectRow = 0; //选择打印模板 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) { // for (int i = 0; i < grdSub.Rows.Count; i++) { selectRow = grdSub.Rows[i].Index; Sub_SetReport(oFrm.sOpenTmp); Report.Print(true); Thread.Sleep(1000); } } } private void Sub_SetReport(string sOpenTmp) { // Report = new GridppReport(); Report.LoadFromFile(ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord); Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); } private void ReportBeforePostRecord()// { try { Report.FieldByName("条码编号").AsString = grdSub.Rows[selectRow].Cells[HTMCol].Value.ToString(); Report.FieldByName("批次").AsString = grdSub.Rows[selectRow].Cells[HBatchNo2Col].Value.ToString(); Report.FieldByName("数量").AsString = grdSub.Rows[selectRow].Cells[HQty2Col].Value.ToString(); Report.FieldByName("源单单号").AsString = grdSub.Rows[selectRow].Cells[HSourceBillNoCol].Value.ToString(); Report.FieldByName("托数").AsString = (grdSub.Rows[selectRow].Cells[HLSH2Col].Value.ToString() + "/" + grdMain.Rows[0].Cells[HBQtyCol].Value.ToString()); Report.FieldByName("规格型号").AsString = grdSub.Rows[selectRow].Cells[HMaterModel2Col].Value.ToString(); Report.FieldByName("物料代码").AsString = grdSub.Rows[selectRow].Cells[HMaterNumber2Col].Value.ToString(); Report.FieldByName("物料名称").AsString = grdSub.Rows[selectRow].Cells[HMaterName2Col].Value.ToString(); CurRows = CurRows + 1; } catch (Exception e) { MessageBox.Show("打印失败!表头:" + e.Message); } } private void ReportFetchRecordByDataTable() { try { BLL.Utility.FillRecordToReport(Report, grdMain, grdPrint, HMaterIDCol); } catch (Exception e) { MessageBox.Show("打印失败!表体:" + e.Message); } } #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 CheckUseOrgID() { DataSet DS; DS = get_ORGANIZATIONSList(); if (DS == null || DS.Tables[0].Rows.Count == 0) { MessageBox.Show("读取组织信息失败2!"); return; } cmbHOrg.Items.Clear(); for (int i = 0; i < DS.Tables[0].Rows.Count; i++) { cmbHOrg.Items.Add(DS.Tables[0].Rows[i]["HName"].ToString()); } if (cmbHOrg.Items.Count > 0) { cmbHOrg.SelectedIndex = 0; } } public DataSet get_ORGANIZATIONSList() { try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); return oCN.RunProcReturn("select * from h_v_CLD_ORGANIZATIONSList", "h_v_CLD_ORGANIZATIONSList"); } catch (Exception e) { return null; } } } }