From 10a392d09c021caf0ca1fca21b424736862f4e48 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期一, 04 九月 2023 13:17:40 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WarM/条码打印/Kf_WeighToBarCode_StationOutBill.cs |  974 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 974 insertions(+), 0 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Kf_WeighToBarCode_StationOutBill.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Kf_WeighToBarCode_StationOutBill.cs"
new file mode 100644
index 0000000..05279c5
--- /dev/null
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Kf_WeighToBarCode_StationOutBill.cs"
@@ -0,0 +1,974 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using gregn6Lib;
+using SQLHelper;
+using DBUtility;
+using System.Threading;
+using System.IO;
+using Pub_Class;
+
+namespace WarM
+{
+    public partial class Kf_WeighToBarCode_StationOutBill : Form
+    {
+        public Kf_WeighToBarCode_StationOutBill()
+        {
+            InitializeComponent();
+        }
+        public frmBillQueryCondition_New frmCondition;
+        public string ModCaption = "娑ょ憾鍗婃垚鍝佺敓鎴愭潯鐮�";
+        public const string ModName = "85";
+        public Int64 HInterID = 0;
+        public string HBillNo = "";
+        public string HBillType = "1202";
+        public Int64 HUnitID = 0;
+        public Int64 HSourceInterID = 0;
+        public Int64 HSourceEntryID = 0;
+        public string HSourceBillNo = "";
+        public string HSourceBillType = "";
+        public Int64 HProcessExchangeInterID = 0;
+        public Int64 HProcessExchangeEntryID = 0;
+        public Int64 HSupID = 0;
+        public double HSourceQty = 0;
+        public string HCusMaterName = "";       //瀹㈡埛鐗╂枡鍚嶇О
+        public string HCusModel = "";           //瀹㈡埛瑙勬牸鍨嬪彿
+        public string HMaker = DBUtility.ClsPub.CurUserName;
+        public Int64 HStockOrgID = DBUtility.ClsPub.HOrgID;
+        public DateTime HDate = DateTime.Today;
+        public long PrintQty = 0;               //鍏佽鏉$爜鎵撳嵃娆℃暟
+        public string PrintQtyCtl = "";         //鏉$爜鎵撳嵃娆℃暟鎺у埗
+        public string UpdatePrintQtyCtl = "";   //鏉$爜鎵撳嵃娆℃暟鏇存柊
+        public string sBarCodeItemID = "";      //鏉$爜鑷鍒�
+        public DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
+        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
+        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+
+        #region  //鍥哄畾浠g爜
+
+        //娓呯┖鐣岄潰
+        public void Sub_ClearBill()
+        {
+            cmbHBarCodeType.Items.Clear();
+            cmbHBarCodeType.Items.Add("鍞竴鏉$爜");
+            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
+            txtHBarCode.Text = "";
+            grdMain.DataSource = null;
+            grdSub.DataSource = null;
+            chkHDYFlag.Checked = true;
+        }
+
+        //绐椾綋鍔犺浇
+        private void Kf_WeighToBarCode_StationOutBill_Load(object sender, EventArgs e)
+        {
+            frmCondition = new frmBillQueryCondition_New();
+            this.Text = ModCaption;
+            Sub_GetSystemParameter();
+        }
+
+        private void initGrid()
+        {
+            DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name);
+            DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub");
+        }
+
+        //鑾峰彇绯荤粺鍙傛暟淇℃伅
+        private void Sub_GetSystemParameter()
+        {
+            //鑾峰彇绯荤粺鍙傛暟
+            ClsXt_SystemParameter oSystemParameter = new ClsXt_SystemParameter();
+            if (oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo) == false)
+            {
+                MessageBox.Show("鑾峰彇绯荤粺鍙傛暟澶辫触锛佸師鍥�:" + DBUtility.ClsPub.sExeReturnInfo, "鎻愮ず");
+                return;
+            }
+            else
+            {
+                PrintQty = oSystemParameter.omodel.BarCode_PrintQty;
+                PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
+                UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
+            }
+        }
+
+        private void timer1_Tick(object sender, EventArgs e)
+        {
+            timer1.Enabled = false;
+            initGrid();
+            this.Sub_ClearBill();//娓呯┖鐣岄潰
+
+            //鑾峰彇鏉$爜ID
+            DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_TempList '" + HMaker + "'," + HStockOrgID.ToString(), "h_p_KF_GetBCPWeighSource_TempList");
+            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
+            {
+                HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //寰楀埌鏂板崟鎹甀D
+            }
+            else if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HBack"]) == 1)
+            {
+                HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //寰楀埌鏂板崟鎹甀D
+            }
+            else
+            {
+                HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
+            }
+            Source_Display();
+            BarCode_Display();
+            if (grdSub.Rows.Count > 0)
+            {
+                grdSub.Rows[0].Selected = true;
+                SourceBill();
+                txtHQty.Focus();
+            }
+            else
+            {
+                txtHBarCode.Focus();
+            }
+        }
+
+        private void grdMain_Paint(object sender, PaintEventArgs e)
+        {
+            GraphicsGrid();
+        }
+
+        private void GraphicsGrid()
+        {
+            DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
+        }
+
+        private void grdSub_Paint(object sender, PaintEventArgs e)
+        {
+            GraphicsGridSub();
+        }
+
+        private void GraphicsGridSub()
+        {
+            DBUtility.Xt_BaseBillFun.GraphicsGrid(grdSub);
+        }
+
+        private Int32 Fun_GetCol(string sCol)
+        {
+            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
+        }
+
+        private Int32 Fun_GetSubCol(string sCol)
+        {
+            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdSub);
+        }
+
+        //淇濆瓨鍒楀
+        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 mrlk_Click(object sender, EventArgs e)
+        {
+            DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
+            DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub");
+        }
+
+        #endregion
+
+        #region  //鍒锋柊
+
+        private void sx_Click_1(object sender, EventArgs e)
+        {
+            timer1.Enabled = true;
+        }
+
+        #endregion
+
+        #region  //鎵撳嵃
+
+        GridppReport Report;
+
+        private void dy_Click_1(object sender, EventArgs e)
+        {
+            //鎵撳嵃鍓嶅垽鏂潯鐮佹槸鍚﹁秴杩囧厑璁稿彲鎵撳嵃娆℃暟
+            if (ReportPrintBegin())
+            {
+                return;
+            }
+
+            //閫夋嫨鎵撳嵃妯℃澘
+            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
+            oFrm.sBillName = ModName;
+            oFrm.sBillModel = ModCaption;
+            oFrm.ShowDialog();
+            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
+            {
+                Sub_SetReport(oFrm.sOpenTmp);
+                Report.Print(false);
+                Thread.Sleep(1000);
+            }
+        }
+
+        //鎵撳嵃鍓嶅垽鏂潯鐮佹槸鍚﹁秴杩囧厑璁稿彲鎵撳嵃娆℃暟
+        private bool ReportPrintBegin()
+        {
+            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
+            string sHRemark = "";
+            sBarCodeItemID = "";
+            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
+            {
+                sBarCodeItemID = sBarCodeItemID + "," + DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
+            }
+            sBarCodeItemID = sBarCodeItemID.Remove(0, 1);
+
+            if (PrintQtyCtl == "Y")
+            {
+                if (oBar.Set_CheckPrintQty(sBarCodeItemID, PrintQty, ref sHRemark))
+                {
+                    MessageBox.Show(sHRemark);
+                    return true;
+                }
+                return false;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        private void Sub_SetReport(string sOpenTmp)
+        {
+            //鍒ゆ柇琛屾暟
+            for (int i = 0; i < grdMain.Rows.Count; i++)
+            {
+                grdMain.Rows[i].Cells[0].Value = "";
+            }
+            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
+            {
+                grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[0].Value = "*";
+            }
+            //
+            Report = new GridppReport();
+            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
+            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
+            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
+            Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
+        }
+
+        //濉叆鍗曟嵁琛ㄥご淇℃伅
+        private void ReportBeforePostRecord()//your report?kao
+        {
+            try
+            {
+                //Report.FieldByName("鐗╂枡浠g爜").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("鐗╂枡浠g爜")].Value.ToString();
+                //Report.FieldByName("鐗╂枡鍚嶇О").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("鐗╂枡鍚嶇О")].Value.ToString();
+                //Report.FieldByName("瑙勬牸鍨嬪彿").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("瑙勬牸鍨嬪彿")].Value.ToString();
+            }
+            catch (Exception e)
+            {
+                MessageBox.Show("鎵撳嵃澶辫触!琛ㄥご锛�" + e.Message);
+            }
+        }
+
+        //濉叆鍗曟嵁琛ㄤ綋淇℃伅
+        private void ReportFetchRecordByDataTable()
+        {
+            try
+            {
+                DataTable ds = new DataTable();
+                BLL.Utility.FillRecordToReport_Sel(Report, grdMain, ds, Fun_GetCol("閫夋嫨"));
+            }
+            catch (Exception e)
+            {
+                MessageBox.Show("鎵撳嵃澶辫触!琛ㄤ綋锛�" + e.Message);
+            }
+        }
+
+        //鎵撳嵃缁撴潫鍚庡洖濉潯鐮佹墦鍗版鏁�
+        private void ReportPrintEnd()
+        {
+            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
+            if (UpdatePrintQtyCtl == "Y")
+            {
+                oBar.Set_UpdatePrintQty(sBarCodeItemID);
+            }
+        }
+
+        #endregion
+
+        #region  //鐢熷崟
+
+        private void hb_Click(object sender, EventArgs e)
+        {
+            this.Sub_SaveBill();
+            timer1.Enabled = true;
+        }
+
+        private bool Sub_SaveBill()
+        {
+            //鏉$爜璁板綍鍒楄〃鏄惁鏈夎褰曞垽鏂�
+            bool b = false;
+            for (int i = 0; i < grdMain.RowCount; i++)
+            {
+                b = true;
+                break;
+            }
+            if (b == false)
+            {
+                MessageBox.Show("褰撳墠鏉$爜璁板綍鍒楄〃鏃犳暟鎹紝涓嶅厑璁哥敓鎴愬崟鎹紒", "鎻愮ず");
+                return false;
+            }
+
+            //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+            string s = "";
+            int sYear = 0;
+            int sPeriod = 0;
+            if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+            {
+                MessageBox.Show(s, "鎻愮ず");
+                return false;
+            }
+
+            try
+            {
+                oCn.BeginTran();
+                DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_StationOutBill " + HInterID.ToString(), "h_p_KF_GetBCPWeighSource_StationOutBill");
+                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
+                {
+                    oCn.RollBack();
+                    MessageBox.Show("鐢熸垚宸ュ簭鍑虹珯姹囨姤鍗曞け璐ワ紝褰撳墠鏉$爜璁板綍鍒楄〃鏃犳暟鎹紒", "鎻愮ず");
+                    return false;
+                }
+                else
+                {
+                    for (int y = 0; y < Ds.Tables[0].Rows.Count; y++)
+                    {
+                        Int64 sInterID = 0;
+                        string sBillNo = "";
+                        string sBillType = "3791";
+                        sInterID = DBUtility.ClsPub.CreateBillID(sBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //寰楀埌鏂板崟鎹甀D
+                        sBillNo = DBUtility.ClsPub.CreateBillCode(sBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);    //寰楀埌鏂板崟鎹彿
+
+                        Int64 sHBarCodeInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HInterID"]);
+                        Int64 sHMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HMaterID"]);
+                        Int64 sHUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HUnitID"]);
+                        string sHBatchNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[y]["HBatchNo"]);
+                        Int64 sHSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSupID"]);
+                        Int64 sHGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HGroupID"]);
+                        Int64 sHDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HDeptID"]);
+                        Int64 sHProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HProcID"]);
+                        Int64 sHCenterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HCenterID"]);
+                        Int64 sHSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSourceID"]);
+                        Int64 sHProcNo = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HLayerNumber"]);
+                        Double sHQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[y]["HQty"]);
+                        Double sHICMOQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[y]["HReadyQty"]);
+                        Int64 sHICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSourceInterID"]);
+                        Int64 sHICMOEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HSourceEntryID"]);
+                        string sHICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[y]["HSourceBillNo"]);
+                        Int64 sHProcExchInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HOrderInterID"]);
+                        Int64 sHProcExchEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[y]["HOrderEntryID"]);
+                        string sHProcExchBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[y]["HOrderBillNo"]);
+
+                        //鐢熸垚宸ュ簭鍑虹珯姹囨姤鍗�    (鏉$爜ID瀛樺叆HMainInterID瀛楁锛�
+                        oCn.RunProc("Insert Into Sc_StationOutBillMain " +
+                        "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" +
+                        ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" +
+                        ",HICMOInterID,HICMOEntryID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
+                        ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID,HPayProcID" +
+                        ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" +
+                        ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
+                        ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
+                        ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID" +
+                        ",HPersonNums,HMachineNums,HEmpNum,HMainInterID,HPRDORGID" +
+                        ") " +
+                        " values('" + sBillType + "','" + sBillType + "'," + sInterID.ToString() + ",'" + sBillNo + "',0,getdate(),'" + DBUtility.ClsPub.CurUserName + "',getdate(),''" +
+                        "," + sYear.ToString() + "," + sPeriod.ToString() + ",'娑ょ憾鍗婃垚鍝佺敓鎴愭潯鐮佹ā鍧楃敓鍗曠敓鎴�','',0,0,0,0" +
+                        "," + sHICMOInterID.ToString() + "," + sHICMOEntryID.ToString() + ",'" + sHICMOBillNo + "',0,0,''," + sHProcExchInterID.ToString() + "," + sHProcExchEntryID.ToString() +
+                        ",'" + sHProcExchBillNo + "'," + sHMaterID.ToString() + "," + sHProcID.ToString() + "," + sHICMOQty.ToString() + "," + sHICMOQty.ToString() + ",getdate()," + sHSourceID.ToString() + ",0" +
+                        "," + sHGroupID.ToString() + "," + sHDeptID.ToString() + ",0,'','','',getdate(),0,0,0,0" +
+                        "," + sHSupID.ToString() + "," + sHQty.ToString() + ",0,0,0," + sHCenterID.ToString() + "," + sHProcNo.ToString() + ",'',''" +
+                        ",0,'','',0" +
+                        ",0,0,0,0,0,0,0,0,0" +
+                        ",0,0,''," + sHBarCodeInterID.ToString() + "," + HStockOrgID.ToString() +
+                        ") ");
+                    }
+
+                    //鍥炲~宸茬敓鍗曠姸鎬�
+                    oCn.RunProc("Update KF_BCPWeighSource_Temp set HRelationInterID=1 where HInterID= " + HInterID.ToString());
+                    MessageBox.Show("鐢熸垚宸ュ簭鍑虹珯姹囨姤鍗曟垚鍔燂紒", "鎻愮ず");
+                    oCn.Commit();
+                    return true;
+                }
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                MessageBox.Show("鐢熸垚宸ュ簭鍑虹珯姹囨姤鍗曞け璐ワ紒" + e.Message);
+                return false;
+            }
+        }
+
+        #endregion
+
+        #region  //閫�鍑�
+
+        private void tc_Click(object sender, EventArgs e)
+        {
+            this.Close();
+        }
+
+        #endregion
+
+        #region  //鎵弿鏉$爜
+
+        private void txtHBarCode_KeyPress(object sender, KeyPressEventArgs e)
+        {
+            if (e.KeyChar == (char)Keys.Return)
+            {
+                if (!AddSource())
+                {
+                    txtHBarCode.Focus();
+                    txtHBarCode.SelectAll();
+                    return;
+                }
+                Source_Display();
+                grdSub.Rows[0].Selected = true;
+                DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
+                SourceBill();
+                txtHBarCode.Text = "";
+                txtHQty.Focus();
+            }
+        }
+
+        private void cmdOK_Click(object sender, EventArgs e)
+        {
+            if (!AddSource())
+            {
+                txtHBarCode.Focus();
+                txtHBarCode.SelectAll();
+                return;
+            }
+            Source_Display();
+            grdSub.Rows[0].Selected = true;
+            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
+            SourceBill();
+            txtHBarCode.Text = "";
+            txtHQty.Focus();
+        }
+
+        private bool AddSource()
+        {
+            //灏嗘壂鎻忓崟鎹彿鍐欏叆涓存椂琛�
+            DataSet ds = oCn.RunProcReturn("exec h_p_Kf_AddSource_BCPWeighToBarCode " + HInterID.ToString() + ",'" + HBillNo + "','" + txtHBarCode.Text.Trim() + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_Kf_AddSource_BCPWeighToBarCode");
+            if (ds == null || ds.Tables[0].Rows.Count == 0)
+            {
+                MessageBox.Show("鎵弿鏉$爜鍐欏叆涓存椂琛ㄥ彂鐢熼敊璇紒", "鎻愮ず");
+                return false;
+            }
+            else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 1)
+            {
+                MessageBox.Show(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]), "鎻愮ず");
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
+        #endregion
+
+        #region  //閫夊崟
+
+        private void cmdSourceBillNo_Click(object sender, EventArgs e)
+        {
+            //鍒濆鍖栧彸杈硅〃澶翠俊鎭�
+            cmbHBarCodeType.Items.Clear();
+            cmbHBarCodeType.Items.Add("鍞竴鏉$爜");
+            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
+
+            if (grdSub.CurrentRow == null)
+            {
+                MessageBox.Show("璇峰湪宸﹁竟鍗曟嵁鍒楄〃涓�夋嫨涓�琛屽崟鎹紒", "鎻愮ず");
+                return;
+            }
+            else if (grdSub.SelectedRows.Count != 1)
+            {
+                MessageBox.Show("涓嶅厑璁稿悓鏃堕�夋嫨澶氳鍗曟嵁锛岃閲嶆柊閫夋嫨鍗曟嵁锛�");
+                return;
+            }
+            else
+            {
+                SourceBill();
+                txtHQty.Focus();
+            }
+        }
+
+        #endregion
+
+        #region  //淇濆瓨
+
+        private void cmdSave_Click(object sender, EventArgs e)
+        {
+            if (!Sub_AllowSave())
+            {
+                return;
+            }
+            SaveBarCode();
+            BarCode_Display();
+            grdMain.Rows[0].Selected = true;
+
+            sBarCodeItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
+            //鑷姩鎵撳嵃
+            if (chkHDYFlag.Checked == true)
+            {
+                //鎵撳嵃鏉$爜
+                Sub_SetReport("鐗╂枡鏉$爜");
+                Report.Print(false);
+                Thread.Sleep(1000);
+            }
+            else
+            {
+                //閫夋嫨鎵撳嵃妯℃澘
+                BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
+                oFrm.sBillName = ModName;
+                oFrm.sBillModel = ModCaption;
+                oFrm.ShowDialog();
+                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
+                {
+                    Sub_SetReport(oFrm.sOpenTmp);
+                    Report.Print(false);
+                    Thread.Sleep(1000);
+                }
+            }
+
+            txtHQty.Text = "";
+            txtHQty.Focus();
+        }
+
+        //鏉$爜鐢熸垚鍓嶅垽鏂�
+        private bool Sub_AllowSave()
+        {
+            //鍒ゆ柇褰撳墠鍗曟嵁ID鏄惁宸蹭笂浼犵敓鎴愬崟鎹�
+            DataSet Ds = oCn.RunProcReturn("select top 1 1 from KF_BCPWeighSource_Temp with(nolock) where HInterID=" + HInterID.ToString() + " and HRelationInterID=1 ", "KF_BCPWeighSource_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
+            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
+            {
+            }
+            else
+            {
+                MessageBox.Show("褰撳墠鏉$爜璁板綍宸茶涓婁紶鐢熸垚鍗曟嵁锛岃閫�鍑哄悗閲嶆柊杩涘叆璇ユā鍧楄繘琛屾潯鐮佺敓鎴愭搷浣滐紒", "鎻愮ず");
+                return false;
+            }
+
+            if (HInterID==0)
+            {
+                MessageBox.Show("鑾峰彇鏉$爜瀵瑰簲鍗曟嵁ID澶辫触锛岃閲嶆柊鍒锋柊鐣岄潰锛�", "鎻愮ず");
+                return false;
+            }
+            else if (DBUtility.ClsPub.isLong(txtHMaterNumber.Tag) == 0)
+            {
+                MessageBox.Show("璇峰厛鎵弿宸ュ簭娴佽浆鍗″彿锛�", "鎻愮ず");
+                return false;
+            }
+            else if (DBUtility.ClsPub.isDoule(txtHQty.Text) == 0)
+            {
+                MessageBox.Show("璇疯緭鍏ユ纭背鏁帮紒", "鎻愮ず");
+                return false;
+            }
+            else if (DBUtility.ClsPub.isDoule(txtHProcID.Tag) == 0)
+            {
+                MessageBox.Show("璇峰厛閫夋嫨宸ュ簭锛�", "鎻愮ず");
+                return false;
+            }
+
+            return true;
+        }
+
+        //鐢熸垚鏉$爜
+        private void SaveBarCode()
+        {
+            int LSHlen = 6;             //娴佹按鍙烽暱搴�
+            Int64 LSH = 0;              //娴佹按鍙�
+            string LSH2 = "";           //娴佹按鍙疯浆鎹㈡垚瀛楃
+            string HMaterID = "";       //鐗╂枡鍐呯爜
+            string HBatchNo = "";       //鎵规
+            string sDate = "";          //鏃ユ湡
+            string sYear = "";          //骞�
+            string sPeriod = "";        //鏈�
+            string sDay = "";           //鏃�
+            string sTMNumber = "";      //鏉$爜鑷畾涔夊墠缂�
+            string TM = "";             //鏉$爜缂栧彿
+            DataSet Ds;
+
+            HMaterID = DBUtility.ClsPub.isStrNull(txtHMaterNumber.Tag);
+            HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
+            //鏃ユ湡鑾峰彇鏂瑰紡
+            sDate = dtpHDate.Value.ToShortDateString();
+            sYear = DBUtility.ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
+            sPeriod = "0" + DBUtility.ClsPub.isDate(sDate).Month.ToString();
+            sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
+            sDay = "0" + DBUtility.ClsPub.isDate(sDate).Day.ToString();
+            sDay = sDay.Substring(sDay.Length - 2, 2);
+            //==================================
+            if (cmbHBarCodeType.Text == "鍞竴鏉$爜")
+            {
+                //鏉$爜鍓嶇紑 = 缁勭粐浠g爜 + 鐗╂枡鍐呯爜 + 骞� + 鏈� + 鏃�
+                sTMNumber = DBUtility.ClsPub.HOrgNumber + HMaterID + sYear + sPeriod + sDay;
+                Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
+                LSH = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
+                LSH = LSH + 1;
+                LSH2 = LSH.ToString();
+                while (LSH2.Length < LSHlen)  //濡傛灉娴佹按鍙峰皬浜�6浣嶆暟鍓嶉潰琛�0
+                {
+                    LSH2 = "0" + LSH2;
+                }
+                TM = sTMNumber + LSH2;
+            }
+            else if (cmbHBarCodeType.Text == "鍝佺鏉$爜")
+            {
+                TM = DBUtility.ClsPub.HOrgNumber + HMaterID;
+            }
+            else if (cmbHBarCodeType.Text == "鎵规鏉$爜")
+            {
+                TM = DBUtility.ClsPub.HOrgNumber + HMaterID + HBatchNo;
+            }
+            else
+            {
+                MessageBox.Show("閿欒鐨勬潯鐮佺被鍨嬶紝涓嶈兘鐢熸垚鏉$爜锛�");
+                return;
+            }
+
+            string HBarCode = "";
+            string HBarCodeType = "";
+            Int64 HMaterID2 = 0;
+            double HQty = 0;            //绫虫暟
+            Int64 HGroupID = 0;
+            Int64 HDeptID = 0;
+            string HProcessExchangeBillNo = "";
+            string HMaterName = "";
+            string HMaterModel = "";
+            Int64 HProcID = 0;
+            Int64 HCenterID = 0;
+            Int64 HSourceID = 0;
+            Int64 HProcNo = 0;
+
+            HBarCode = TM;
+            HBarCodeType = DBUtility.ClsPub.isStrNull(cmbHBarCodeType.Text);
+            HMaterID2 = DBUtility.ClsPub.isLong(txtHMaterNumber.Tag);
+            HQty = DBUtility.ClsPub.isDoule(txtHQty.Text);
+            HGroupID = DBUtility.ClsPub.isLong(txtHGroupID.Tag);
+            HDeptID = DBUtility.ClsPub.isLong(txtHDeptName.Tag);
+            HProcessExchangeBillNo = DBUtility.ClsPub.isStrNull(txtHBillNo.Text);
+            HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text);
+            HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text);
+            HProcID = DBUtility.ClsPub.isLong(txtHProcID.Tag);
+            HCenterID = DBUtility.ClsPub.isLong(txtHCenterID.Tag);
+            HSourceID = DBUtility.ClsPub.isLong(txtHSourceID.Tag);
+            HProcNo = DBUtility.ClsPub.isLong(txtHProcNo.Text);
+
+            try
+            {
+                oCn.BeginTran();
+                //鍐欏叆鏉$爜妗f    (瀹㈡埛鐗╂枡鍚嶇ОHCusMaterName瀛樺叆HMaterialModel瀛楁锛屽鎴疯鏍煎瀷鍙稨CusModel瀛樺叆HCusModel瀛楁锛屾祦姘村彿瀛樺叆HLayerNumber瀛楁锛屾簮鍗曟暟閲忓瓨鍏ReadyQty瀛楁锛�
+                oCn.RunProc("Insert into Gy_BarCodeBill " +
+                "(HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate,HMaterialJQty,HMaterialMQty " +
+                ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HGiveAwayFlag " +
+                ",HOrderInterID,HOrderEntryID,HOrderBillNo,HCustomQty1,HMaterialModel,HCusModel " +
+                ",HProcID,HCenterID,HSourceID,HLayerNumber,HReadyQty " +
+                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HLogo " +
+                ") Values ("
+                + " '" + HBarCode + "','" + HBarCodeType + "'," + HMaterID2.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                + ",'" + HBatchNo + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + HMaker + "',getdate(),0," + HQty.ToString()
+                + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "',''"
+                + ", 1,1," + HDeptID.ToString() + ",0,0,''"
+                + ", 0,'',getdate(),'','" + sDate + "',0,0"
+                + ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",''," + HInterID.ToString() + ",0"
+                + ", " + HProcessExchangeInterID.ToString() + "," + HProcessExchangeEntryID.ToString() + ",'" + HProcessExchangeBillNo + "',0,'" + HCusMaterName + "','" + HCusModel + "'"
+                + ", " + HProcID.ToString() + "," + HCenterID.ToString() + "," + HSourceID.ToString() + "," + HProcNo.ToString() + "," + HSourceQty.ToString()
+                + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','','1')");
+
+                //鍥炲~鏈�澶ф祦姘村彿
+                oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "',1 ");
+                //鍥炲~婧愬崟涓存椂琛℉InterID
+                oCn.RunProc("update a set a.HInterID=" + HInterID.ToString() + ",a.HRelationInterID= 0 from KF_BCPWeighSource_Temp a where a.HInterID<>" + HInterID.ToString() + " and a.HMaker='" + HMaker + "' and a.HSourceBillNo='" + HProcessExchangeBillNo + "'");
+                oCn.Commit();
+            }
+            catch (Exception e)
+            {
+                oCn.RollBack();
+                MessageBox.Show("鏉$爜鐢熸垚澶辫触锛�" + e.Message);
+            }
+        }
+
+        #endregion
+
+        #region  //杩斿洖淇℃伅
+
+        //杩斿洖婧愬崟鍒楄〃淇℃伅
+        private void SourceBill()
+        {
+            txtHBillNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鍗曟嵁鍙�")].Value);
+            txtHDeptName.Tag = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HDeptID")].Value);
+            txtHDeptName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("杞﹂棿")].Value);
+            txtHMaterNumber.Tag = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterID")].Value);
+            txtHMaterNumber.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鐗╂枡浠g爜")].Value);
+            txtHMaterName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鐗╂枡鍚嶇О")].Value);
+            txtHMaterModel.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("瑙勬牸鍨嬪彿")].Value);
+            txtHBatchNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鎵瑰彿")].Value);
+            txtHICMOBillNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鐢熶骇璁㈠崟")].Value);
+            HUnitID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HUnitID")].Value);
+            HSourceInterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceInterID")].Value);
+            HSourceEntryID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceEntryID")].Value);
+            HSourceBillNo = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鐢熶骇璁㈠崟")].Value);
+            HSourceBillType = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceBillType")].Value);
+            HSourceQty = DBUtility.ClsPub.isDoule(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鏁伴噺")].Value);
+            HProcessExchangeInterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HProcessExchangeInterID")].Value);
+            HSupID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSupID")].Value);
+            HCusMaterName = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusMaterName")].Value);
+            HCusModel = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusModel")].Value);
+        }
+
+        //杩斿洖婧愬崟鍒楄〃淇℃伅
+        private void Source_Display()
+        {
+            DataSet DSet = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_TempList '" + HMaker + "'," + HStockOrgID.ToString(), "h_p_KF_GetBCPWeighSource_TempList");
+            grdSub.DataSource = DSet.Tables[0].DefaultView;
+            //鍐荤粨
+            int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
+            string s = frmCondition.cmbHComplete.Text;
+            DBUtility.Xt_BaseBillFun.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol);
+            //鐢荤嚎
+            GraphLine();
+        }
+
+        //杩斿洖鏉$爜璁板綍鍒楄〃淇℃伅
+        private void BarCode_Display()
+        {
+            DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID desc", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
+            grdMain.DataSource = DSet.Tables[0].DefaultView;
+            //鍐荤粨
+            int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
+            string s = frmCondition.cmbHComplete.Text;
+            DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
+            //鐢荤嚎
+            GraphLine();
+        }
+
+        private void GraphLine()
+        {
+            int MainIDCol = Fun_GetCol("hmainid");
+            int SubIDCol = Fun_GetCol("hsubid");
+            string s = frmCondition.cmbHComplete.Text;
+            long n = 0;
+            DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s, ref n);
+
+            int MainIDCol2 = Fun_GetSubCol("hmainid");
+            int SubIDCol2 = Fun_GetSubCol("hsubid");
+            string s2 = frmCondition.cmbHComplete.Text;
+            long n2 = 0;
+            DBUtility.Xt_BaseBillFun.GraphLine(grdSub, MainIDCol2, SubIDCol2, s2, ref n2);
+        }
+
+        #endregion
+
+        #region  //浣滃簾
+        private void cmdZF_Click(object sender, EventArgs e)
+        {
+            if (grdMain.CurrentRow == null)
+            {
+                MessageBox.Show("璇峰厛閫夋嫨闇�瑕佷綔搴熺殑鏉$爜锛�", "鎻愮ず");
+                return;
+            }
+            else
+            {
+                if (MessageBox.Show("纭畾瑕佷綔搴熸墍閫夋潯鐮侊紵", "鎻愮ず", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+                {
+                    return;
+                }
+                else
+                {
+                    string HRemark = "";
+                    string HItemID = "";
+                    string HBarCode = "";
+                    string HBarCode2 = "";
+                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
+                    {
+                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
+                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + "'";
+                        if (i != 0 && i % 100 == 0)
+                        {
+                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        else
+                        {
+                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("浣滃簾鏍囪")].Value) != "")
+                        {
+                            HRemark = HRemark + "銆�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                    }
+                    if (HRemark != "")
+                    {
+                        MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細"+ HRemark.Remove(0, 1)+" 宸蹭綔搴燂紝涓嶅厑璁搁噸澶嶄綔搴燂紒", "鎻愮ず");
+                        return;
+                    }
+                    HItemID = HItemID.Remove(0, 1);     //鍘绘帀瀛楃涓茬涓�涓瓧绗�
+                    HBarCode = HBarCode.Remove(0, 1);
+                    HBarCode2 = HBarCode2.Remove(0, 1);
+
+                    try
+                    {
+                        oCn.BeginTran();
+                        string[] NewBarCode;
+                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
+
+                        //浣滃簾鏉$爜
+                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=1,HDeleteMan='" + DBUtility.ClsPub.CurUserName + "',HDeleteDate=getdate() where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
+                        //鍐欏叆绯荤粺鏃ュ織
+                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
+                        {
+                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','浣滃簾鏉$爜锛�" + NewBarCode[i] + "','娑ょ憾鍗婃垚鍝佺敓鎴愭潯鐮佹ā鍧�','" + DBUtility.ClsPub.IPAddress + "','浣滃簾'", ref DBUtility.ClsPub.sExeReturnInfo);
+                        }
+                        oCn.Commit();
+                    }
+                    catch (Exception e2)
+                    {
+                        oCn.RollBack();
+                        MessageBox.Show("浣滃簾鏉$爜澶辫触锛�" + e2.Message, "鎻愮ず");
+                        return;
+                    }
+                    //鍒锋柊鏉$爜璁板綍鍒楄〃淇℃伅
+                    BarCode_Display();
+                    MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HBarCode.Remove(0, 1) + " 浣滃簾鎴愬姛锛�", "鎻愮ず");
+                }
+            }
+        }
+
+        #endregion
+
+        #region  //鍙嶄綔搴�
+        private void cmdFZF_Click(object sender, EventArgs e)
+        {
+            if (grdMain.CurrentRow == null)
+            {
+                MessageBox.Show("璇峰厛閫夋嫨闇�瑕佸弽浣滃簾鐨勬潯鐮侊紒", "鎻愮ず");
+                return;
+            }
+            else
+            {
+                if (MessageBox.Show("纭畾瑕佸弽浣滃簾鎵�閫夋潯鐮侊紵", "鎻愮ず", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+                {
+                    return;
+                }
+                else
+                {
+                    string HRemark = "";
+                    string HItemID = "";
+                    string HBarCode = "";
+                    string HBarCode2 = "";
+                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
+                    {
+                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
+                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + "'";
+                        if (i != 0 && i % 100 == 0)
+                        {
+                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        else
+                        {
+                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("浣滃簾鏍囪")].Value) == "")
+                        {
+                            HRemark = HRemark + "銆�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                    }
+                    if (HRemark != "")
+                    {
+                        MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HRemark.Remove(0, 1) + " 鏈綔搴燂紝涓嶅厑璁稿弽浣滃簾锛�", "鎻愮ず");
+                        return;
+                    }
+                    HItemID = HItemID.Remove(0, 1);     //鍘绘帀瀛楃涓茬涓�涓瓧绗�
+                    HBarCode = HBarCode.Remove(0, 1);
+                    HBarCode2 = HBarCode2.Remove(0, 1);
+
+                    try
+                    {
+                        oCn.BeginTran();
+                        string[] NewBarCode;
+                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
+
+                        //鍙嶄綔搴熸潯鐮�
+                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=0,HDeleteMan='',HDeleteDate=null where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
+
+                        //鍐欏叆绯荤粺鏃ュ織
+                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
+                        {
+                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','鍙嶄綔搴熸潯鐮侊細" + NewBarCode[i] + "','娑ょ憾鍗婃垚鍝佺敓鎴愭潯鐮佹ā鍧�','" + DBUtility.ClsPub.IPAddress + "','鍙嶄綔搴�'", ref DBUtility.ClsPub.sExeReturnInfo);
+                        }
+                        oCn.Commit();
+                    }
+                    catch (Exception e2)
+                    {
+                        oCn.RollBack();
+                        MessageBox.Show("鍙嶄綔搴熸潯鐮佸け璐ワ紒" + e2.Message, "鎻愮ず");
+                        return;
+                    }
+                    //鍒锋柊鏉$爜璁板綍鍒楄〃淇℃伅
+                    BarCode_Display();
+                    MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HBarCode.Remove(0, 1) + " 鍙嶄綔搴熸垚鍔燂紒", "鎻愮ず");
+                }
+            }
+        }
+
+
+        #endregion
+
+        #region  //宸ュ簭閫夋嫨
+
+        private void cmdHProcID_Click(object sender, EventArgs e)
+        {
+            DAL.ClsGy_Process_View oProcess = new DAL.ClsGy_Process_View();
+            if (oProcess.RefreshView())
+            {
+                this.txtHProcID.Text = oProcess.oModel.HName;
+                this.txtHProcID.Tag = oProcess.oModel.HItemID.ToString();
+            }
+
+            if(oProcess.oModel.HItemID!=0 && HProcessExchangeInterID != 0)
+            {
+                //鏍规嵁杞崱涓籌D銆佸伐搴忓甫鍑烘祦杞崱涓婄浉搴旀祦姘村彿銆佺彮缁勩�佸伐浣滀腑蹇冦�佺敓浜ц祫婧�
+                DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetBCPWeighSource_ProcID " + HProcessExchangeInterID.ToString() + "," + oProcess.oModel.HItemID.ToString(), "h_p_KF_GetBCPWeighSource_ProcID");
+                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
+                {
+                    this.txtHProcID.Text = "";
+                    this.txtHProcID.Tag = 0;
+                    MessageBox.Show("鎵�閫夊伐搴忎笉鍦ㄥ綋鍓嶅伐搴忔祦杞崱涓嬶紝璇烽噸鏂伴�夋嫨姝g‘宸ュ簭锛�");
+                    return;
+                }
+                else
+                {
+                    HProcessExchangeEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
+                    txtHProcNo.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcNo"]);
+                    txtHCenterID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCenterID"]);
+                    txtHCenterID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCenterName"]);
+                    txtHGroupID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
+                    txtHGroupID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HGroupName"]);
+                    txtHSourceID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]);
+                    txtHSourceID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceName"]);
+                }
+            }
+        }
+
+        private void txtHProcID_TextChanged(object sender, EventArgs e)
+        {
+            BLL.ClsPub_BLL.Sub_ClearText(txtHProcID);
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1