From 25529a26e5844c82ac2179f34d88bca86ca3a82e Mon Sep 17 00:00:00 2001 From: ouyangqing <ouyangqing@DESKTOP-B85SG1D> Date: 星期三, 20 一月 2021 13:34:48 +0800 Subject: [PATCH] nothing --- SCM/单据资料/Sc_ICMOReportToBarCode.cs | 4060 +++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 2,577 insertions(+), 1,483 deletions(-) diff --git "a/SCM/\345\215\225\346\215\256\350\265\204\346\226\231/Sc_ICMOReportToBarCode.cs" "b/SCM/\345\215\225\346\215\256\350\265\204\346\226\231/Sc_ICMOReportToBarCode.cs" index 4839e59..390c1d8 100644 --- "a/SCM/\345\215\225\346\215\256\350\265\204\346\226\231/Sc_ICMOReportToBarCode.cs" +++ "b/SCM/\345\215\225\346\215\256\350\265\204\346\226\231/Sc_ICMOReportToBarCode.cs" @@ -1,544 +1,1638 @@ -锘縰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 Pub_Class; -using System.Threading; -using System.IO.Ports; - -namespace SCM -{ - public partial class Sc_ICMOReportToBarCode : Form - { - public Sc_ICMOReportToBarCode() - { - InitializeComponent(); - } - - public frmBillQueryCondition_Base frmCondition; - public string ModCaption = "鎴愬搧鍒嗗垏鍦ㄧ嚎妫�楠�"; - public string ModName = "Sc_ICMOReportToBarCode"; - public string HSourceBillTypeID = ""; //鍗曟嵁绫诲瀷 - public string HSourceBillType = ""; //鍗曟嵁绫诲瀷鍚嶇О - public string HSourceBillNo = ""; - public Int64 HSourceInterID = 0; - public Int64 HSourceEntryID = 0; - public int HTMCol = 0; - public int HMaterIDCol = 1; - Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum(); - public Int32 iTopRow = 0;//鐢绘í绾� - SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); - // - - #region 鍥哄畾浠g爜 - - //娓呯┖鐣岄潰 - public void Sub_ClearBill() - { - //娓呯┖鐣岄潰鎺т欢 for 鎺т欢 - foreach (Control ct in gbUp.Controls) - { - switch (ct.GetType().Name) - { - case "ComboBox": - ((ComboBox)ct).SelectedIndex = 0; - break; - case "TextBox": - ((TextBox)ct).Text = ""; - break; - case "DateTimePicker": - ((DateTimePicker)ct).Value = DateTime.Today; - break; - default: - break; - } - } - // - txtHMaker.Text = ClsPub.CurUserName; - initGrid(); - } - - private void Sc_ICMOReportToBarCode_Load(object sender, EventArgs e) - { - //璁剧疆鍔ㄦ�乁RL - oWeb.Url = SCM.ClsPub1.WEBSURL; - // - frmCondition = new frmBillQueryCondition_Base(); - this.Text = ModCaption; - oSumGrid.ogrdMain = grdSub; //鍒濆鍖� new - oSumGrid.oGridsum = grdSum; - initGrid(); - //cmbHBillType.SelectedIndex = 0; - //cmbHSourceBillType.SelectedIndex = 0; - cmbFQMB.Items.Add(this.Text); - cmbFQMB.SelectedIndex = 0; - - if(DBUtility.ClsPub.CurUserName.ToLower()=="admin") - { - txtHDQQty.ReadOnly = false; - txtHKSQty.ReadOnly = false; - } - } - - //鍒濆鍖栫綉鏍� - private void initGrid() - { - ClsPub1.initGridList(grdMain, this.Name); - ClsPub1.initGridList(grdSub, this.Name + "grdSub"); - ClsPub1.initGridFst(grdEmp, this.Name + "grdEmp"); - grdMain.RowTemplate.Height = 30; - grdMain.RowTemplate.MinimumHeight = 30; - grdMain.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); - grdMain.ReadOnly = true; - - grdSub.RowTemplate.Height = 30; - grdSub.RowTemplate.MinimumHeight = 30; - grdSub.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); - grdSub.ReadOnly = true; - - grdEmp.RowTemplate.Height = 30; - grdEmp.RowTemplate.MinimumHeight = 30; - grdEmp.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); - grdEmp.ReadOnly = false; - //DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name); - //DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub"); - DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); - DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); - DBUtility.Xt_BaseBillFun.GetGrid(grdEmp, this.Name + "grdEmp"); - } - - //鏃堕棿鎺т欢 - private void timer1_Tick(object sender, EventArgs e) - { - timer1.Enabled=false; - Sub_ClearBill(); - } - - private void timer2_Tick(object sender, EventArgs e) - { - timer2.Enabled = false; - // - if (ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini").Contains("娌℃湁鎵惧埌")==false) - { - txtPortName.Text = ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - txtBaudRate.Text = ClsIni.ReadIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - cmbParity.Text = ClsIni.ReadIni("COMINFO", "cmbParity", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - txtDataBits.Text = ClsIni.ReadIni("COMINFO", "txtDataBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - cmbStopBits.Text = ClsIni.ReadIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - txtHSend0.Text = ClsIni.ReadIni("COMINFO", "txtHSend0", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - txtHSend.Text = ClsIni.ReadIni("COMINFO", "txtHSend", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - txtHSourceID.Text = ClsIni.ReadIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - txtHSourceID.Tag = ClsIni.ReadIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - this.Text = this.Text + "-" + txtHSourceID.Text; - } - - //鍒濆鍖栦覆鍙� - ComDevice = new SerialPort(); - ComDevice.DataReceived += new SerialDataReceivedEventHandler(Com_DataReceived);//缁戝畾浜嬩欢 - string[] PortNames = SerialPort.GetPortNames(); - //鎵撳紑涓插彛 - OpenCom(); - } - - //閫�鍑� - private void tc_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void grdMain_Paint(object sender, PaintEventArgs e) - { - GraphicsGrid(); - } - - private void GraphicsGrid() - { - //鐢诲簳绾� - DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain); - //鐢绘í绾� - DBUtility.Xt_BaseBillFun.GraphicsRowGrid(grdMain, iTopRow, iTopRow + 50, Fun_GetCol("hmainid")); - } - - private Int32 Fun_GetCol(string sCol) - { - return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); - } - - //淇濆瓨鍒楀 - private void bclk_Click(object sender, EventArgs e) - { - DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); - DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub"); - DBUtility.Xt_BaseBillFun.SaveGrid(grdEmp, this.Name + "grdEmp"); - } - - //榛樿鍒楀 - private void mrlk_Click(object sender, EventArgs e) - { - DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); - DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub"); - DBUtility.Xt_BaseBillFun.DefaultGridView(grdEmp, this.Name + "grdEmp"); - } - - #endregion - - - #region 杩斿洖婧愬崟淇℃伅 - - private void xd_Click(object sender, EventArgs e) - { - - } - - - private void Display(string SourceBillType, Int64 HSourceBillInterID, Int64 HSourceBillEntryID) - { - DataSet Ds; - //鐢熶骇璁㈠崟 - if (SourceBillType == "鐢熶骇璁㈠崟") - { - //寰楀埌淇℃伅 - Ds = oWeb.getDataSetBySQL("select * from h_v_IFCLD_ICMOList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IFCLD_ICMOList", ref DBUtility.ClsPub.sExeReturnInfo); - //鍐欏叆淇℃伅 - Sub_WriteInForm(Ds.Tables[0], 0); - } - //鏀舵枡閫氱煡鍗� - if (SourceBillType == "鏀舵枡閫氱煡鍗�") - { - //寰楀埌淇℃伅 - Ds = oWeb.getDataSetBySQL("select * from h_v_IF_POInStockList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); - //鍐欏叆淇℃伅 - Sub_WriteInForm(Ds.Tables[0], 0); - } - //鐢熶骇姹囨姤鍗� - if (SourceBillType == "鐢熶骇姹囨姤鍗�") - { - //寰楀埌淇℃伅 - Ds = oWeb.getDataSetBySQL("select * from h_v_IF_ICMOReportBillList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); - //鍐欏叆淇℃伅 - Sub_WriteInForm(Ds.Tables[0], 0); - } - } - - //鏍规嵁TABLE鍐欏叆鐣岄潰 - private void Sub_WriteInForm(DataTable oTable, int i) - { - try - { - txtHSourceBillNo.Text = oTable.Rows[0]["鍗曟嵁鍙�"].ToString(); - txtHMaterNumber.Text = oTable.Rows[0]["鐗╂枡浠g爜"].ToString(); - txtHOldMaterNumber.Text = oTable.Rows[0]["鏃х墿鏂欑紪鐮�"].ToString(); - txtHMaterNumber.Tag = oTable.Rows[0]["HMaterID"].ToString(); - txtHMaterName.Text = oTable.Rows[0]["鐗╂枡鍚嶇О"].ToString(); - txtHMaterName.Tag = oTable.Rows[0]["HMaterID"].ToString(); - txtHMaterModel.Text = oTable.Rows[0]["瑙勬牸鍨嬪彿"].ToString(); - txtHUnitName.Text = oTable.Rows[0]["璁¢噺鍗曚綅"].ToString(); - txtHUnitName.Tag = oTable.Rows[0]["HUnitID"].ToString(); - txtHBatchNo.Text = oTable.Rows[0]["鎵规"].ToString(); - txtHSumQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["鏁伴噺"].ToString(), 1); - txtHRelationQty.Text = oTable.Rows[0]["宸茬敓鎴愭潯鐮佹暟閲�"].ToString(); - txtHSYQty.Text = oTable.Rows[0]["鏈敓鎴愭潯鐮佹暟閲�"].ToString(); - txtHKSQty.Text = lblHNowQty.Text; - txtHDQQty.Text = lblHNowQty.Text; - if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text)>0) - { - txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); - } - else - { - txtHSJQty.Text = "0"; - } - DisplayMain(); - //DisplaySub(); - } - catch(Exception e) - { - MessageBox.Show("璇诲彇澶辫触锛�" + e.Message); - } - } - - - private void DisplayMain() - { - DataSet DSet; - string sSql = ""; - string sWhere = ""; - //杩囨护鏉′欢 - sSql = " exec h_p_Sc_ICMOReportToBarCode_All '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); - // - DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_All", ref DBUtility.ClsPub.sExeReturnInfo); - //鐢熸垚棣栬鏍囬 - if (DSet == null) - { - MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); - return; - } - // - if (DSet.Tables[0].Rows.Count>0) - { - grdMain.DataSource = DSet.Tables[0].DefaultView; - } - //鍐荤粨 - int FrCol = DBUtility.ClsPub.isInt(0); - string s = "鏄�"; - ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol); - //鐢荤嚎 - //Total(); - /////////////////////////////////////////// - if (DSet.Tables[1].Rows.Count > 0) - { - grdSub.DataSource = DSet.Tables[1].DefaultView; - } - //鍐荤粨 - ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); - ///////////////////////////// - txtHRelationQty.Text = DBUtility.ClsPub.isDoule(DSet.Tables[2].Rows[0]["鍏宠仈鏁伴噺"], 1); - if(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text)>=0) - { - txtHSYQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text), 1); - } - else - { - txtHSYQty.Text = "0"; - } - ////////////////////////// - } - - private void DisplaySub() - { - DataSet DSet; - string sSql = ""; - string sWhere = ""; - //杩囨护鏉′欢 - sSql = " exec h_p_Sc_ICMOReportToBarCode_Sub '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); - - // - DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_Sub", ref DBUtility.ClsPub.sExeReturnInfo); - //鐢熸垚棣栬鏍囬 - if (DSet == null) - { - MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); - return; - } - // - grdSub.DataSource = DSet.Tables[0].DefaultView; - - - //鍐荤粨 - int FrCol = DBUtility.ClsPub.isInt(0); - string s = "鏄�"; - ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); - //鐢荤嚎 - //Total(); - } - - - #endregion - - - #region //鎵撳嵃璁剧疆 - - GridppReport Report; - string sBarCode = ""; - - //棰勮 - int CurRows = 0; - - - - - - - - #endregion - - - #region 鐣岄潰鎺т欢澶勭悊 - - private void cmdHDeptID_Click(object sender, EventArgs e) - { - SCM.ClsIF_Department_View oDept = new SCM.ClsIF_Department_View(); - string sWhere = ""; - if (oDept.RefreshView(sWhere)) - { - this.txtHDeptID.Text = oDept.oModel.HName; - this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString(); - } - else - { - this.txtHDeptID.Text = ""; - } - } - - private void txtHDeptID_TextChanged(object sender, EventArgs e) - { - BLL.ClsPub_BLL.Sub_ClearText(txtHDeptID); - } - - #endregion - - - //閫夋嫨婧愬崟 - private void cmdHSourceBillNo_Click(object sender, EventArgs e) - { - Gy_SourceBillList_Touch oGy_SourceBillList_Touch = new Gy_SourceBillList_Touch(); - oGy_SourceBillList_Touch.HSourceBillType = HSourceBillType;//绫诲瀷鍚嶇О - oGy_SourceBillList_Touch.ShowDialog(); - if (oGy_SourceBillList_Touch.OKTag == 1) - { - //鏍规嵁閫変腑鐨勬簮鍗曞唴鐮佸拰瀛愬唴鐮侊紝杩斿洖鐩稿簲淇℃伅 - HSourceEntryID = oGy_SourceBillList_Touch.HSelEntryID; - HSourceInterID = oGy_SourceBillList_Touch.HSelInterID; - HSourceBillTypeID = oGy_SourceBillList_Touch.HSourceBillTypeID; - HSourceBillNo = oGy_SourceBillList_Touch.HSourceBillNo; - Display(HSourceBillType, oGy_SourceBillList_Touch.HSelInterID, oGy_SourceBillList_Touch.HSelEntryID); - } - else - { - HSourceEntryID = 0; - HSourceInterID = 0; - HSourceBillTypeID = ""; - HSourceBillNo = ""; - } - } - - // - private void cmdCancel_Click(object sender, EventArgs e) - { - CloseCom(); - this.Close(); - } - - private void label19_Click(object sender, EventArgs e) - { - - } - - public bool SaveBill(string sType) - { - try - { - int LSHlen = 2; //娴佹按鍙烽暱搴� - int SumLen = 10; //鎬婚暱搴� - string TM = ""; //鏉$爜 - string HNumber = ""; //鐗╂枡浠g爜 - double HSumQty = 0; //浜у搧鏁伴噺 - double HMinQty = 0; //鏈�灏忓寘瑁呮暟 - int HBQty = 0; //绠辨暟 - double HQty = 0; //鏁伴噺 - string WeiShu = ""; //灏炬暟 - int LSH = 0; //娴佹按鍙� - string LSH2 = ""; //娴佹按鍙疯浆鎹㈡垚瀛楃 - string sDate = ""; //鏃ユ湡 - string sYear = ""; //骞� - string sPeriod = ""; //鏈� - string sDay = ""; //鏃� - string HBatchNo = ""; //鎵规 - int k = 0; - int n = 0; //鍚屼竴鎵圭敓鎴愭潯鐮佷腑鐨勭鍑犳潯 - string sTMNumber = ""; //鏉$爜鑷畾涔夊墠缂� - DataSet Ds; - // - string HWei = ""; //灏炬暟 - HBarCode = ""; - string HBarCodeType = ""; - Int64 HMaterID = 0; - Int64 HAuxPropID = 0; - Int64 HUnitID = 0; - double HQty2 = 0; - string HBatchNo2 = ""; - Int64 HSupID = 0; - Int64 HGroupID = 0; - int HPrintQty = 0; - Int64 HBarcodeNo = 0; //鎵樺彿 - Int64 HBarcodeQtys = 0; //鎬绘墭鏁� - Int64 HDeptID = 0; - Int64 HWhID = 0; - Int64 HSPID = 0; - string HRemark = ""; - string HMaterName = ""; - string HMaterModel = ""; - string HPinfan = ""; - string HMTONo = ""; - Int64 HCusID = 0; - string HCusType = ""; - DateTime HEndDate; - string HWorkLineName = ""; - DateTime HBeginDate; - string HSeOrderBillNo = ""; - string HJiaYe2 = ""; - string HPressModel = ""; - string HCusModel = ""; - string HMaterialModel = ""; - string HColor = ""; - string HLogo = ""; - string HPackageSize = ""; - double HMaterialJQty = 0; - double HMaterialMQty = 0; - string HCustomBatchNo = ""; - string HGBBarCode = ""; - string POOrderBillNo = ""; - // - cmdHSaveBill.Enabled = false; - //鍒ゆ柇鏄惁瀛樺湪 婧愬崟淇℃伅锛� - if (HSourceInterID <= 0 || HSourceEntryID <= 0 || DBUtility.ClsPub.isLong(txtHMaterName.Tag) <= 0 || DBUtility.ClsPub.isLong(txtHUnitName.Tag) <= 0)//鍒ゆ柇鏄惁鏈夋簮鍗� - { - MessageBox.Show("娌℃湁閫夊崟锛�"); - cmdHSaveBill.Enabled = true; - return false; - } - if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) >= 0) - { - txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� - lblHRelQty.Text = txtHSJQty.Text; - } - else - { - if (MessageBox.Show("褰撳墠绫虫暟灏忎簬寮�濮嬬背鏁帮紝鏄惁纭畾瑕佹竻闆跺紑濮嬬背鏁�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) - { - txtHKSQty.Text = "0"; - txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� - lblHRelQty.Text = txtHSJQty.Text; - } - } - if (DBUtility.ClsPub.isDoule(txtHSJQty.Text) <= 0) - { - MessageBox.Show("褰撳墠鏁伴噺涓嶈兘灏忎簬绛変簬0锛�"); - cmdHSaveBill.Enabled = true; - return false; - } - //if (DBUtility.ClsPub.isDoule(txtHSYQty.Text) <= 0) - //{ - // MessageBox.Show("鍓╀綑鏁伴噺宸茬粡涓�0锛屼笉鑳藉湪瑁佸垏锛�"); - // cmdHSaveBill.Enabled = true; - // return false; - //} - if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0 || DBUtility.ClsPub.isLong(txtHEmpID2.Tag) == 0 ) - { - MessageBox.Show("鑱屽憳1鎴栬�呰亴鍛�2娌℃湁閫夋嫨锛�"); - cmdHSaveBill.Enabled = true; - return false; - } - if (DBUtility.ClsPub.isLong(txtHGroupID.Tag) == 0 ) - { - MessageBox.Show("鐝粍娌℃湁閫夋嫨锛�"); - cmdHSaveBill.Enabled = true; - return false; - } - - - //鏍规嵁婧愬崟 鐢熸垚鏉″舰鐮� 骞朵繚瀛樺鏁版嵁搴� - HNumber = DBUtility.ClsPub.isStrNull(txtHMaterName.Tag); - HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text); - sDate = dtpHDate.Value.ToShortDateString(); - 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(); +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> parent of 07a1f92 (no) +锘縰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 Pub_Class; +using System.Threading; +using System.IO.Ports; + +namespace SCM +{ + public partial class Sc_ICMOReportToBarCode : Form + { + public Sc_ICMOReportToBarCode() + { + InitializeComponent(); + } + + public frmBillQueryCondition_Base frmCondition; + public string ModCaption = "鎴愬搧鍒嗗垏鍦ㄧ嚎妫�楠�"; + public string ModName = "Sc_ICMOReportToBarCode"; + public string HSourceBillTypeID = ""; //鍗曟嵁绫诲瀷 + public string HSourceBillType = ""; //鍗曟嵁绫诲瀷鍚嶇О + public string HSourceBillNo = ""; + public Int64 HSourceInterID = 0; + public Int64 HSourceEntryID = 0; + public int HTMCol = 0; + public int HMaterIDCol = 1; + Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum(); + public Int32 iTopRow = 0;//鐢绘í绾� + SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); + // + + #region 鍥哄畾浠g爜 + + //娓呯┖鐣岄潰 + public void Sub_ClearBill() + { + //娓呯┖鐣岄潰鎺т欢 for 鎺т欢 + foreach (Control ct in gbUp.Controls) + { + switch (ct.GetType().Name) + { + case "ComboBox": + ((ComboBox)ct).SelectedIndex = 0; + break; + case "TextBox": + ((TextBox)ct).Text = ""; + break; + case "DateTimePicker": + ((DateTimePicker)ct).Value = DateTime.Today; + break; + default: + break; + } + } + // + txtHMaker.Text = ClsPub.CurUserName; + initGrid(); + } + + private void Sc_ICMOReportToBarCode_Load(object sender, EventArgs e) + { + //璁剧疆鍔ㄦ�乁RL + oWeb.Url = SCM.ClsPub1.WEBSURL; + // + frmCondition = new frmBillQueryCondition_Base(); + this.Text = ModCaption; + oSumGrid.ogrdMain = grdSub; //鍒濆鍖� new + oSumGrid.oGridsum = grdSum; + initGrid(); + //cmbHBillType.SelectedIndex = 0; + //cmbHSourceBillType.SelectedIndex = 0; + cmbFQMB.Items.Add(this.Text); + cmbFQMB.SelectedIndex = 0; + + if(DBUtility.ClsPub.CurUserName.ToLower()=="admin") + { + txtHDQQty.ReadOnly = false; + txtHKSQty.ReadOnly = false; + } + } + + //鍒濆鍖栫綉鏍� + private void initGrid() + { + ClsPub1.initGridList(grdMain, this.Name); + ClsPub1.initGridList(grdSub, this.Name + "grdSub"); + ClsPub1.initGridFst(grdEmp, this.Name + "grdEmp"); + grdMain.RowTemplate.Height = 30; + grdMain.RowTemplate.MinimumHeight = 30; + grdMain.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdMain.ReadOnly = true; + + grdSub.RowTemplate.Height = 30; + grdSub.RowTemplate.MinimumHeight = 30; + grdSub.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdSub.ReadOnly = true; + + grdEmp.RowTemplate.Height = 30; + grdEmp.RowTemplate.MinimumHeight = 30; + grdEmp.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdEmp.ReadOnly = false; + //DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name); + //DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.GetGrid(grdEmp, this.Name + "grdEmp"); + } + + //鏃堕棿鎺т欢 + private void timer1_Tick(object sender, EventArgs e) + { + timer1.Enabled=false; + Sub_ClearBill(); + } + + private void timer2_Tick(object sender, EventArgs e) + { + timer2.Enabled = false; + // + if (ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini").Contains("娌℃湁鎵惧埌")==false) + { + txtPortName.Text = ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtBaudRate.Text = ClsIni.ReadIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + cmbParity.Text = ClsIni.ReadIni("COMINFO", "cmbParity", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtDataBits.Text = ClsIni.ReadIni("COMINFO", "txtDataBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + cmbStopBits.Text = ClsIni.ReadIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSend0.Text = ClsIni.ReadIni("COMINFO", "txtHSend0", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSend.Text = ClsIni.ReadIni("COMINFO", "txtHSend", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSourceID.Text = ClsIni.ReadIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSourceID.Tag = ClsIni.ReadIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + this.Text = this.Text + "-" + txtHSourceID.Text; + } + + //鍒濆鍖栦覆鍙� + ComDevice = new SerialPort(); + ComDevice.DataReceived += new SerialDataReceivedEventHandler(Com_DataReceived);//缁戝畾浜嬩欢 + string[] PortNames = SerialPort.GetPortNames(); + //鎵撳紑涓插彛 + OpenCom(); + } + + //閫�鍑� + private void tc_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void grdMain_Paint(object sender, PaintEventArgs e) + { + GraphicsGrid(); + } + + private void GraphicsGrid() + { + //鐢诲簳绾� + DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain); + //鐢绘í绾� + DBUtility.Xt_BaseBillFun.GraphicsRowGrid(grdMain, iTopRow, iTopRow + 50, Fun_GetCol("hmainid")); + } + + private Int32 Fun_GetCol(string sCol) + { + return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); + } + + //淇濆瓨鍒楀 + private void bclk_Click(object sender, EventArgs e) + { + DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.SaveGrid(grdEmp, this.Name + "grdEmp"); + } + + //榛樿鍒楀 + private void mrlk_Click(object sender, EventArgs e) + { + DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.DefaultGridView(grdEmp, this.Name + "grdEmp"); + } + + #endregion + + + #region 杩斿洖婧愬崟淇℃伅 + + private void xd_Click(object sender, EventArgs e) + { + + } + + + private void Display(string SourceBillType, Int64 HSourceBillInterID, Int64 HSourceBillEntryID) + { + DataSet Ds; + //鐢熶骇璁㈠崟 + if (SourceBillType == "鐢熶骇璁㈠崟") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IFCLD_ICMOList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IFCLD_ICMOList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + //鏀舵枡閫氱煡鍗� + if (SourceBillType == "鏀舵枡閫氱煡鍗�") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IF_POInStockList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + //鐢熶骇姹囨姤鍗� + if (SourceBillType == "鐢熶骇姹囨姤鍗�") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IF_ICMOReportBillList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + } + + //鏍规嵁TABLE鍐欏叆鐣岄潰 + private void Sub_WriteInForm(DataTable oTable, int i) + { + try + { + txtHSourceBillNo.Text = oTable.Rows[0]["鍗曟嵁鍙�"].ToString(); + txtHMaterNumber.Text = oTable.Rows[0]["鐗╂枡浠g爜"].ToString(); + txtHOldMaterNumber.Text = oTable.Rows[0]["鏃х墿鏂欑紪鐮�"].ToString(); + txtHMaterNumber.Tag = oTable.Rows[0]["HMaterID"].ToString(); + txtHMaterName.Text = oTable.Rows[0]["鐗╂枡鍚嶇О"].ToString(); + txtHMaterName.Tag = oTable.Rows[0]["HMaterID"].ToString(); + txtHMaterModel.Text = oTable.Rows[0]["瑙勬牸鍨嬪彿"].ToString(); + txtHUnitName.Text = oTable.Rows[0]["璁¢噺鍗曚綅"].ToString(); + txtHUnitName.Tag = oTable.Rows[0]["HUnitID"].ToString(); + txtHBatchNo.Text = oTable.Rows[0]["鎵规"].ToString(); + txtHSumQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["鏁伴噺"].ToString(), 1); + txtHRelationQty.Text = oTable.Rows[0]["宸茬敓鎴愭潯鐮佹暟閲�"].ToString(); + txtHSYQty.Text = oTable.Rows[0]["鏈敓鎴愭潯鐮佹暟閲�"].ToString(); + txtHKSQty.Text = lblHNowQty.Text; + txtHDQQty.Text = lblHNowQty.Text; + if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text)>0) + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); + } + else + { + txtHSJQty.Text = "0"; + } + DisplayMain(); + //DisplaySub(); + } + catch(Exception e) + { + MessageBox.Show("璇诲彇澶辫触锛�" + e.Message); + } + } + + + private void DisplayMain() + { + DataSet DSet; + string sSql = ""; + string sWhere = ""; + //杩囨护鏉′欢 + sSql = " exec h_p_Sc_ICMOReportToBarCode_All '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); + // + DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_All", ref DBUtility.ClsPub.sExeReturnInfo); + //鐢熸垚棣栬鏍囬 + if (DSet == null) + { + MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); + return; + } + // + if (DSet.Tables[0].Rows.Count>0) + { + grdMain.DataSource = DSet.Tables[0].DefaultView; + } + //鍐荤粨 + int FrCol = DBUtility.ClsPub.isInt(0); + string s = "鏄�"; + ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol); + //鐢荤嚎 + //Total(); + /////////////////////////////////////////// + if (DSet.Tables[1].Rows.Count > 0) + { + grdSub.DataSource = DSet.Tables[1].DefaultView; + } + //鍐荤粨 + ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); + ///////////////////////////// + txtHRelationQty.Text = DBUtility.ClsPub.isDoule(DSet.Tables[2].Rows[0]["鍏宠仈鏁伴噺"], 1); + if(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text)>=0) + { + txtHSYQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text), 1); + } + else + { + txtHSYQty.Text = "0"; + } + ////////////////////////// + } + + private void DisplaySub() + { + DataSet DSet; + string sSql = ""; + string sWhere = ""; + //杩囨护鏉′欢 + sSql = " exec h_p_Sc_ICMOReportToBarCode_Sub '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); + + // + DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_Sub", ref DBUtility.ClsPub.sExeReturnInfo); + //鐢熸垚棣栬鏍囬 + if (DSet == null) + { + MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); + return; + } + // + grdSub.DataSource = DSet.Tables[0].DefaultView; + + + //鍐荤粨 + int FrCol = DBUtility.ClsPub.isInt(0); + string s = "鏄�"; + ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); + //鐢荤嚎 + //Total(); + } + + + #endregion + + + #region //鎵撳嵃璁剧疆 + + GridppReport Report; + string sBarCode = ""; + + //棰勮 + int CurRows = 0; + + + + + + + + #endregion + + + #region 鐣岄潰鎺т欢澶勭悊 + + private void cmdHDeptID_Click(object sender, EventArgs e) + { + SCM.ClsIF_Department_View oDept = new SCM.ClsIF_Department_View(); + string sWhere = ""; + if (oDept.RefreshView(sWhere)) + { + this.txtHDeptID.Text = oDept.oModel.HName; + this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString(); + } + else + { + this.txtHDeptID.Text = ""; + } + } + + private void txtHDeptID_TextChanged(object sender, EventArgs e) + { + BLL.ClsPub_BLL.Sub_ClearText(txtHDeptID); + } + + #endregion + + + //閫夋嫨婧愬崟 + private void cmdHSourceBillNo_Click(object sender, EventArgs e) + { + Gy_SourceBillList_Touch oGy_SourceBillList_Touch = new Gy_SourceBillList_Touch(); + oGy_SourceBillList_Touch.HSourceBillType = HSourceBillType;//绫诲瀷鍚嶇О + oGy_SourceBillList_Touch.ShowDialog(); + if (oGy_SourceBillList_Touch.OKTag == 1) + { + //鏍规嵁閫変腑鐨勬簮鍗曞唴鐮佸拰瀛愬唴鐮侊紝杩斿洖鐩稿簲淇℃伅 + HSourceEntryID = oGy_SourceBillList_Touch.HSelEntryID; + HSourceInterID = oGy_SourceBillList_Touch.HSelInterID; + HSourceBillTypeID = oGy_SourceBillList_Touch.HSourceBillTypeID; + HSourceBillNo = oGy_SourceBillList_Touch.HSourceBillNo; + Display(HSourceBillType, oGy_SourceBillList_Touch.HSelInterID, oGy_SourceBillList_Touch.HSelEntryID); + } + else + { + HSourceEntryID = 0; + HSourceInterID = 0; + HSourceBillTypeID = ""; + HSourceBillNo = ""; + } + } + + // + private void cmdCancel_Click(object sender, EventArgs e) + { + CloseCom(); + this.Close(); + } + + private void label19_Click(object sender, EventArgs e) + { + + } + + public bool SaveBill(string sType) + { + try + { + int LSHlen = 2; //娴佹按鍙烽暱搴� + int SumLen = 10; //鎬婚暱搴� + string TM = ""; //鏉$爜 + string HNumber = ""; //鐗╂枡浠g爜 + double HSumQty = 0; //浜у搧鏁伴噺 + double HMinQty = 0; //鏈�灏忓寘瑁呮暟 + int HBQty = 0; //绠辨暟 + double HQty = 0; //鏁伴噺 + string WeiShu = ""; //灏炬暟 + int LSH = 0; //娴佹按鍙� + string LSH2 = ""; //娴佹按鍙疯浆鎹㈡垚瀛楃 + string sDate = ""; //鏃ユ湡 + string sYear = ""; //骞� + string sPeriod = ""; //鏈� + string sDay = ""; //鏃� + string HBatchNo = ""; //鎵规 + int k = 0; + int n = 0; //鍚屼竴鎵圭敓鎴愭潯鐮佷腑鐨勭鍑犳潯 + string sTMNumber = ""; //鏉$爜鑷畾涔夊墠缂� + DataSet Ds; + // + string HWei = ""; //灏炬暟 + HBarCode = ""; + string HBarCodeType = ""; + Int64 HMaterID = 0; + Int64 HAuxPropID = 0; + Int64 HUnitID = 0; + double HQty2 = 0; + string HBatchNo2 = ""; + Int64 HSupID = 0; + Int64 HGroupID = 0; + int HPrintQty = 0; + Int64 HBarcodeNo = 0; //鎵樺彿 + Int64 HBarcodeQtys = 0; //鎬绘墭鏁� + Int64 HDeptID = 0; + Int64 HWhID = 0; + Int64 HSPID = 0; + string HRemark = ""; + string HMaterName = ""; + string HMaterModel = ""; + string HPinfan = ""; + string HMTONo = ""; + Int64 HCusID = 0; + string HCusType = ""; + DateTime HEndDate; + string HWorkLineName = ""; + DateTime HBeginDate; + string HSeOrderBillNo = ""; + string HJiaYe2 = ""; + string HPressModel = ""; + string HCusModel = ""; + string HMaterialModel = ""; + string HColor = ""; + string HLogo = ""; + string HPackageSize = ""; + double HMaterialJQty = 0; + double HMaterialMQty = 0; + string HCustomBatchNo = ""; + string HGBBarCode = ""; + string POOrderBillNo = ""; + // + cmdHSaveBill.Enabled = false; + //鍒ゆ柇鏄惁瀛樺湪 婧愬崟淇℃伅锛� + if (HSourceInterID <= 0 || HSourceEntryID <= 0 || DBUtility.ClsPub.isLong(txtHMaterName.Tag) <= 0 || DBUtility.ClsPub.isLong(txtHUnitName.Tag) <= 0)//鍒ゆ柇鏄惁鏈夋簮鍗� + { + MessageBox.Show("娌℃湁閫夊崟锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) >= 0) + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + else + { + if (MessageBox.Show("褰撳墠绫虫暟灏忎簬寮�濮嬬背鏁帮紝鏄惁纭畾瑕佹竻闆跺紑濮嬬背鏁�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) + { + txtHKSQty.Text = "0"; + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + } + if (DBUtility.ClsPub.isDoule(txtHSJQty.Text) <= 0) + { + MessageBox.Show("褰撳墠鏁伴噺涓嶈兘灏忎簬绛変簬0锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + //if (DBUtility.ClsPub.isDoule(txtHSYQty.Text) <= 0) + //{ + // MessageBox.Show("鍓╀綑鏁伴噺宸茬粡涓�0锛屼笉鑳藉湪瑁佸垏锛�"); + // cmdHSaveBill.Enabled = true; + // return false; + //} + if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0 || DBUtility.ClsPub.isLong(txtHEmpID2.Tag) == 0 ) + { + MessageBox.Show("鑱屽憳1鎴栬�呰亴鍛�2娌℃湁閫夋嫨锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + if (DBUtility.ClsPub.isLong(txtHGroupID.Tag) == 0 ) + { + MessageBox.Show("鐝粍娌℃湁閫夋嫨锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + + + //鏍规嵁婧愬崟 鐢熸垚鏉″舰鐮� 骞朵繚瀛樺鏁版嵁搴� + HNumber = DBUtility.ClsPub.isStrNull(txtHMaterName.Tag); + HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text); + sDate = dtpHDate.Value.ToShortDateString(); + 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(); +<<<<<<< HEAD +======= +锘縰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 Pub_Class; +using System.Threading; +using System.IO.Ports; + +namespace SCM +{ + public partial class Sc_ICMOReportToBarCode : Form + { + public Sc_ICMOReportToBarCode() + { + InitializeComponent(); + } + + public frmBillQueryCondition_Base frmCondition; + public string ModCaption = "鎴愬搧鍒嗗垏鍦ㄧ嚎妫�楠�"; + public string ModName = "Sc_ICMOReportToBarCode"; + public string HSourceBillTypeID = ""; //鍗曟嵁绫诲瀷 + public string HSourceBillType = ""; //鍗曟嵁绫诲瀷鍚嶇О + public string HSourceBillNo = ""; + public Int64 HSourceInterID = 0; + public Int64 HSourceEntryID = 0; + public int HTMCol = 0; + public int HMaterIDCol = 1; + Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum(); + public Int32 iTopRow = 0;//鐢绘í绾� + SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); + // + + #region 鍥哄畾浠g爜 + + //娓呯┖鐣岄潰 + public void Sub_ClearBill() + { + //娓呯┖鐣岄潰鎺т欢 for 鎺т欢 + foreach (Control ct in gbUp.Controls) + { + switch (ct.GetType().Name) + { + case "ComboBox": + ((ComboBox)ct).SelectedIndex = 0; + break; + case "TextBox": + ((TextBox)ct).Text = ""; + break; + case "DateTimePicker": + ((DateTimePicker)ct).Value = DateTime.Today; + break; + default: + break; + } + } + // + txtHMaker.Text = ClsPub.CurUserName; + initGrid(); + } + + private void Sc_ICMOReportToBarCode_Load(object sender, EventArgs e) + { + //璁剧疆鍔ㄦ�乁RL + oWeb.Url = SCM.ClsPub1.WEBSURL; + // + frmCondition = new frmBillQueryCondition_Base(); + this.Text = ModCaption; + oSumGrid.ogrdMain = grdSub; //鍒濆鍖� new + oSumGrid.oGridsum = grdSum; + initGrid(); + //cmbHBillType.SelectedIndex = 0; + //cmbHSourceBillType.SelectedIndex = 0; + cmbFQMB.Items.Add(this.Text); + cmbFQMB.SelectedIndex = 0; + + if(DBUtility.ClsPub.CurUserName.ToLower()=="admin") + { + txtHDQQty.ReadOnly = false; + txtHKSQty.ReadOnly = false; + } + } + + //鍒濆鍖栫綉鏍� + private void initGrid() + { + ClsPub1.initGridList(grdMain, this.Name); + ClsPub1.initGridList(grdSub, this.Name + "grdSub"); + ClsPub1.initGridFst(grdEmp, this.Name + "grdEmp"); + grdMain.RowTemplate.Height = 30; + grdMain.RowTemplate.MinimumHeight = 30; + grdMain.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdMain.ReadOnly = true; + + grdSub.RowTemplate.Height = 30; + grdSub.RowTemplate.MinimumHeight = 30; + grdSub.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdSub.ReadOnly = true; + + grdEmp.RowTemplate.Height = 30; + grdEmp.RowTemplate.MinimumHeight = 30; + grdEmp.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdEmp.ReadOnly = false; + //DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name); + //DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.GetGrid(grdEmp, this.Name + "grdEmp"); + } + + //鏃堕棿鎺т欢 + private void timer1_Tick(object sender, EventArgs e) + { + timer1.Enabled=false; + Sub_ClearBill(); + } + + private void timer2_Tick(object sender, EventArgs e) + { + timer2.Enabled = false; + // + if (ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini").Contains("娌℃湁鎵惧埌")==false) + { + txtPortName.Text = ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtBaudRate.Text = ClsIni.ReadIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + cmbParity.Text = ClsIni.ReadIni("COMINFO", "cmbParity", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtDataBits.Text = ClsIni.ReadIni("COMINFO", "txtDataBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + cmbStopBits.Text = ClsIni.ReadIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSend0.Text = ClsIni.ReadIni("COMINFO", "txtHSend0", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSend.Text = ClsIni.ReadIni("COMINFO", "txtHSend", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSourceID.Text = ClsIni.ReadIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSourceID.Tag = ClsIni.ReadIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + this.Text = this.Text + "-" + txtHSourceID.Text; + } + + //鍒濆鍖栦覆鍙� + ComDevice = new SerialPort(); + ComDevice.DataReceived += new SerialDataReceivedEventHandler(Com_DataReceived);//缁戝畾浜嬩欢 + string[] PortNames = SerialPort.GetPortNames(); + //鎵撳紑涓插彛 + OpenCom(); + } + + //閫�鍑� + private void tc_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void grdMain_Paint(object sender, PaintEventArgs e) + { + GraphicsGrid(); + } + + private void GraphicsGrid() + { + //鐢诲簳绾� + DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain); + //鐢绘í绾� + DBUtility.Xt_BaseBillFun.GraphicsRowGrid(grdMain, iTopRow, iTopRow + 50, Fun_GetCol("hmainid")); + } + + private Int32 Fun_GetCol(string sCol) + { + return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); + } + + //淇濆瓨鍒楀 + private void bclk_Click(object sender, EventArgs e) + { + DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.SaveGrid(grdEmp, this.Name + "grdEmp"); + } + + //榛樿鍒楀 + private void mrlk_Click(object sender, EventArgs e) + { + DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.DefaultGridView(grdEmp, this.Name + "grdEmp"); + } + + #endregion + + + #region 杩斿洖婧愬崟淇℃伅 + + private void xd_Click(object sender, EventArgs e) + { + + } + + + private void Display(string SourceBillType, Int64 HSourceBillInterID, Int64 HSourceBillEntryID) + { + DataSet Ds; + //鐢熶骇璁㈠崟 + if (SourceBillType == "鐢熶骇璁㈠崟") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IFCLD_ICMOList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IFCLD_ICMOList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + //鏀舵枡閫氱煡鍗� + if (SourceBillType == "鏀舵枡閫氱煡鍗�") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IF_POInStockList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + //鐢熶骇姹囨姤鍗� + if (SourceBillType == "鐢熶骇姹囨姤鍗�") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IF_ICMOReportBillList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + } + + //鏍规嵁TABLE鍐欏叆鐣岄潰 + private void Sub_WriteInForm(DataTable oTable, int i) + { + try + { + txtHSourceBillNo.Text = oTable.Rows[0]["鍗曟嵁鍙�"].ToString(); + txtHMaterNumber.Text = oTable.Rows[0]["鐗╂枡浠g爜"].ToString(); + txtHOldMaterNumber.Text = oTable.Rows[0]["鏃х墿鏂欑紪鐮�"].ToString(); + txtHMaterNumber.Tag = oTable.Rows[0]["HMaterID"].ToString(); + txtHMaterName.Text = oTable.Rows[0]["鐗╂枡鍚嶇О"].ToString(); + txtHMaterName.Tag = oTable.Rows[0]["HMaterID"].ToString(); + txtHMaterModel.Text = oTable.Rows[0]["瑙勬牸鍨嬪彿"].ToString(); + txtHUnitName.Text = oTable.Rows[0]["璁¢噺鍗曚綅"].ToString(); + txtHUnitName.Tag = oTable.Rows[0]["HUnitID"].ToString(); + txtHBatchNo.Text = oTable.Rows[0]["鎵规"].ToString(); + txtHSumQty.Text = oTable.Rows[0]["鏁伴噺"].ToString(); + txtHRelationQty.Text = oTable.Rows[0]["宸茬敓鎴愭潯鐮佹暟閲�"].ToString(); + txtHSYQty.Text = oTable.Rows[0]["鏈敓鎴愭潯鐮佹暟閲�"].ToString(); + txtHKSQty.Text = lblHNowQty.Text; + txtHDQQty.Text = lblHNowQty.Text; + if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text)>0) + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); + } + else + { + txtHSJQty.Text = "0"; + } + DisplayMain(); + //DisplaySub(); + } + catch(Exception e) + { + MessageBox.Show("璇诲彇澶辫触锛�" + e.Message); + } + } + + + private void DisplayMain() + { + DataSet DSet; + string sSql = ""; + string sWhere = ""; + //杩囨护鏉′欢 + sSql = " exec h_p_Sc_ICMOReportToBarCode_All '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); + // + DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_All", ref DBUtility.ClsPub.sExeReturnInfo); + //鐢熸垚棣栬鏍囬 + if (DSet == null) + { + MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); + return; + } + // + if (DSet.Tables[0].Rows.Count>0) + { + grdMain.DataSource = DSet.Tables[0].DefaultView; + } + //鍐荤粨 + int FrCol = DBUtility.ClsPub.isInt(0); + string s = "鏄�"; + ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol); + //鐢荤嚎 + //Total(); + /////////////////////////////////////////// + if (DSet.Tables[1].Rows.Count > 0) + { + grdSub.DataSource = DSet.Tables[1].DefaultView; + } + //鍐荤粨 + ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); + ///////////////////////////// + txtHRelationQty.Text = DBUtility.ClsPub.isDoule(DSet.Tables[2].Rows[0]["鍏宠仈鏁伴噺"], 1); + if(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text)>=0) + { + txtHSYQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text), 1); + } + else + { + txtHSYQty.Text = "0"; + } + ////////////////////////// + } + + private void DisplaySub() + { + DataSet DSet; + string sSql = ""; + string sWhere = ""; + //杩囨护鏉′欢 + sSql = " exec h_p_Sc_ICMOReportToBarCode_Sub '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); + + // + DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_Sub", ref DBUtility.ClsPub.sExeReturnInfo); + //鐢熸垚棣栬鏍囬 + if (DSet == null) + { + MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); + return; + } + // + grdSub.DataSource = DSet.Tables[0].DefaultView; + + + //鍐荤粨 + int FrCol = DBUtility.ClsPub.isInt(0); + string s = "鏄�"; + ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); + //鐢荤嚎 + //Total(); + } + + + #endregion + + + #region //鎵撳嵃璁剧疆 + + GridppReport Report; + string sBarCode = ""; + + //棰勮 + int CurRows = 0; + + + + + + + + #endregion + + + #region 鐣岄潰鎺т欢澶勭悊 + + private void cmdHDeptID_Click(object sender, EventArgs e) + { + SCM.ClsIF_Department_View oDept = new SCM.ClsIF_Department_View(); + string sWhere = ""; + if (oDept.RefreshView(sWhere)) + { + this.txtHDeptID.Text = oDept.oModel.HName; + this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString(); + } + else + { + this.txtHDeptID.Text = ""; + } + } + + private void txtHDeptID_TextChanged(object sender, EventArgs e) + { + BLL.ClsPub_BLL.Sub_ClearText(txtHDeptID); + } + + #endregion + + + //閫夋嫨婧愬崟 + private void cmdHSourceBillNo_Click(object sender, EventArgs e) + { + Gy_SourceBillList_Touch oGy_SourceBillList_Touch = new Gy_SourceBillList_Touch(); + oGy_SourceBillList_Touch.HSourceBillType = HSourceBillType;//绫诲瀷鍚嶇О + oGy_SourceBillList_Touch.ShowDialog(); + if (oGy_SourceBillList_Touch.OKTag == 1) + { + //鏍规嵁閫変腑鐨勬簮鍗曞唴鐮佸拰瀛愬唴鐮侊紝杩斿洖鐩稿簲淇℃伅 + HSourceEntryID = oGy_SourceBillList_Touch.HSelEntryID; + HSourceInterID = oGy_SourceBillList_Touch.HSelInterID; + HSourceBillTypeID = oGy_SourceBillList_Touch.HSourceBillTypeID; + HSourceBillNo = oGy_SourceBillList_Touch.HSourceBillNo; + Display(HSourceBillType, oGy_SourceBillList_Touch.HSelInterID, oGy_SourceBillList_Touch.HSelEntryID); + } + else + { + HSourceEntryID = 0; + HSourceInterID = 0; + HSourceBillTypeID = ""; + HSourceBillNo = ""; + } + } + + // + private void cmdCancel_Click(object sender, EventArgs e) + { + CloseCom(); + this.Close(); + } + + private void label19_Click(object sender, EventArgs e) + { + + } + + public bool SaveBill(string sType) + { + try + { + int LSHlen = 2; //娴佹按鍙烽暱搴� + int SumLen = 10; //鎬婚暱搴� + string TM = ""; //鏉$爜 + string HNumber = ""; //鐗╂枡浠g爜 + double HSumQty = 0; //浜у搧鏁伴噺 + double HMinQty = 0; //鏈�灏忓寘瑁呮暟 + int HBQty = 0; //绠辨暟 + double HQty = 0; //鏁伴噺 + string WeiShu = ""; //灏炬暟 + int LSH = 0; //娴佹按鍙� + string LSH2 = ""; //娴佹按鍙疯浆鎹㈡垚瀛楃 + string sDate = ""; //鏃ユ湡 + string sYear = ""; //骞� + string sPeriod = ""; //鏈� + string sDay = ""; //鏃� + string HBatchNo = ""; //鎵规 + int k = 0; + int n = 0; //鍚屼竴鎵圭敓鎴愭潯鐮佷腑鐨勭鍑犳潯 + string sTMNumber = ""; //鏉$爜鑷畾涔夊墠缂� + DataSet Ds; + // + string HWei = ""; //灏炬暟 + HBarCode = ""; + string HBarCodeType = ""; + Int64 HMaterID = 0; + Int64 HAuxPropID = 0; + Int64 HUnitID = 0; + double HQty2 = 0; + string HBatchNo2 = ""; + Int64 HSupID = 0; + Int64 HGroupID = 0; + int HPrintQty = 0; + Int64 HBarcodeNo = 0; //鎵樺彿 + Int64 HBarcodeQtys = 0; //鎬绘墭鏁� + Int64 HDeptID = 0; + Int64 HWhID = 0; + Int64 HSPID = 0; + string HRemark = ""; + string HMaterName = ""; + string HMaterModel = ""; + string HPinfan = ""; + string HMTONo = ""; + Int64 HCusID = 0; + string HCusType = ""; + DateTime HEndDate; + string HWorkLineName = ""; + DateTime HBeginDate; + string HSeOrderBillNo = ""; + string HJiaYe2 = ""; + string HPressModel = ""; + string HCusModel = ""; + string HMaterialModel = ""; + string HColor = ""; + string HLogo = ""; + string HPackageSize = ""; + double HMaterialJQty = 0; + double HMaterialMQty = 0; + string HCustomBatchNo = ""; + string HGBBarCode = ""; + string POOrderBillNo = ""; + // + cmdHSaveBill.Enabled = false; + //鍒ゆ柇鏄惁瀛樺湪 婧愬崟淇℃伅锛� + if (HSourceInterID <= 0 || HSourceEntryID <= 0 || DBUtility.ClsPub.isLong(txtHMaterName.Tag) <= 0 || DBUtility.ClsPub.isLong(txtHUnitName.Tag) <= 0)//鍒ゆ柇鏄惁鏈夋簮鍗� + { + MessageBox.Show("娌℃湁閫夊崟锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) >= 0) + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + else + { + if (MessageBox.Show("褰撳墠绫虫暟灏忎簬寮�濮嬬背鏁帮紝鏄惁纭畾瑕佹竻闆跺紑濮嬬背鏁�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) + { + txtHKSQty.Text = "0"; + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + } + if (DBUtility.ClsPub.isDoule(txtHSJQty.Text) <= 0) + { + MessageBox.Show("褰撳墠鏁伴噺涓嶈兘灏忎簬绛変簬0锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + //if (DBUtility.ClsPub.isDoule(txtHSYQty.Text) <= 0) + //{ + // MessageBox.Show("鍓╀綑鏁伴噺宸茬粡涓�0锛屼笉鑳藉湪瑁佸垏锛�"); + // cmdHSaveBill.Enabled = true; + // return false; + //} + if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0 || DBUtility.ClsPub.isLong(txtHEmpID2.Tag) == 0 ) + { + MessageBox.Show("鑱屽憳1鎴栬�呰亴鍛�2娌℃湁閫夋嫨锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + if (DBUtility.ClsPub.isLong(txtHGroupID.Tag) == 0 ) + { + MessageBox.Show("鐝粍娌℃湁閫夋嫨锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + + + //鏍规嵁婧愬崟 鐢熸垚鏉″舰鐮� 骞朵繚瀛樺鏁版嵁搴� + HNumber = DBUtility.ClsPub.isStrNull(txtHMaterName.Tag); + HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text); + sDate = dtpHDate.Value.ToShortDateString(); + 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(); +>>>>>>> parent of d95a654 (nothing) +======= +>>>>>>> parent of 07a1f92 (no) +======= +锘縰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 Pub_Class; +using System.Threading; +using System.IO.Ports; + +namespace SCM +{ + public partial class Sc_ICMOReportToBarCode : Form + { + public Sc_ICMOReportToBarCode() + { + InitializeComponent(); + } + + public frmBillQueryCondition_Base frmCondition; + public string ModCaption = "鎴愬搧鍒嗗垏鍦ㄧ嚎妫�楠�"; + public string ModName = "Sc_ICMOReportToBarCode"; + public string HSourceBillTypeID = ""; //鍗曟嵁绫诲瀷 + public string HSourceBillType = ""; //鍗曟嵁绫诲瀷鍚嶇О + public string HSourceBillNo = ""; + public Int64 HSourceInterID = 0; + public Int64 HSourceEntryID = 0; + public int HTMCol = 0; + public int HMaterIDCol = 1; + Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum(); + public Int32 iTopRow = 0;//鐢绘í绾� + SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); + // + + #region 鍥哄畾浠g爜 + + //娓呯┖鐣岄潰 + public void Sub_ClearBill() + { + //娓呯┖鐣岄潰鎺т欢 for 鎺т欢 + foreach (Control ct in gbUp.Controls) + { + switch (ct.GetType().Name) + { + case "ComboBox": + ((ComboBox)ct).SelectedIndex = 0; + break; + case "TextBox": + ((TextBox)ct).Text = ""; + break; + case "DateTimePicker": + ((DateTimePicker)ct).Value = DateTime.Today; + break; + default: + break; + } + } + // + txtHMaker.Text = ClsPub.CurUserName; + initGrid(); + } + + private void Sc_ICMOReportToBarCode_Load(object sender, EventArgs e) + { + //璁剧疆鍔ㄦ�乁RL + oWeb.Url = SCM.ClsPub1.WEBSURL; + // + frmCondition = new frmBillQueryCondition_Base(); + this.Text = ModCaption; + oSumGrid.ogrdMain = grdSub; //鍒濆鍖� new + oSumGrid.oGridsum = grdSum; + initGrid(); + //cmbHBillType.SelectedIndex = 0; + //cmbHSourceBillType.SelectedIndex = 0; + cmbFQMB.Items.Add(this.Text); + cmbFQMB.SelectedIndex = 0; + + if(DBUtility.ClsPub.CurUserName.ToLower()=="admin") + { + txtHDQQty.ReadOnly = false; + txtHKSQty.ReadOnly = false; + } + } + + //鍒濆鍖栫綉鏍� + private void initGrid() + { + ClsPub1.initGridList(grdMain, this.Name); + ClsPub1.initGridList(grdSub, this.Name + "grdSub"); + ClsPub1.initGridFst(grdEmp, this.Name + "grdEmp"); + grdMain.RowTemplate.Height = 30; + grdMain.RowTemplate.MinimumHeight = 30; + grdMain.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdMain.ReadOnly = true; + + grdSub.RowTemplate.Height = 30; + grdSub.RowTemplate.MinimumHeight = 30; + grdSub.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdSub.ReadOnly = true; + + grdEmp.RowTemplate.Height = 30; + grdEmp.RowTemplate.MinimumHeight = 30; + grdEmp.RowsDefaultCellStyle.Font = new Font("瀹嬩綋", 15); + grdEmp.ReadOnly = false; + //DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name); + //DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.GetGrid(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.GetGrid(grdEmp, this.Name + "grdEmp"); + } + + //鏃堕棿鎺т欢 + private void timer1_Tick(object sender, EventArgs e) + { + timer1.Enabled=false; + Sub_ClearBill(); + } + + private void timer2_Tick(object sender, EventArgs e) + { + timer2.Enabled = false; + // + if (ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini").Contains("娌℃湁鎵惧埌")==false) + { + txtPortName.Text = ClsIni.ReadIni("COMINFO", "txtPortName", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtBaudRate.Text = ClsIni.ReadIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + cmbParity.Text = ClsIni.ReadIni("COMINFO", "cmbParity", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtDataBits.Text = ClsIni.ReadIni("COMINFO", "txtDataBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + cmbStopBits.Text = ClsIni.ReadIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSend0.Text = ClsIni.ReadIni("COMINFO", "txtHSend0", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSend.Text = ClsIni.ReadIni("COMINFO", "txtHSend", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSourceID.Text = ClsIni.ReadIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + txtHSourceID.Tag = ClsIni.ReadIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + this.Text = this.Text + "-" + txtHSourceID.Text; + } + + //鍒濆鍖栦覆鍙� + ComDevice = new SerialPort(); + ComDevice.DataReceived += new SerialDataReceivedEventHandler(Com_DataReceived);//缁戝畾浜嬩欢 + string[] PortNames = SerialPort.GetPortNames(); + //鎵撳紑涓插彛 + OpenCom(); + } + + //閫�鍑� + private void tc_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void grdMain_Paint(object sender, PaintEventArgs e) + { + GraphicsGrid(); + } + + private void GraphicsGrid() + { + //鐢诲簳绾� + DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain); + //鐢绘í绾� + DBUtility.Xt_BaseBillFun.GraphicsRowGrid(grdMain, iTopRow, iTopRow + 50, Fun_GetCol("hmainid")); + } + + private Int32 Fun_GetCol(string sCol) + { + return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); + } + + //淇濆瓨鍒楀 + private void bclk_Click(object sender, EventArgs e) + { + DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.SaveGrid(grdEmp, this.Name + "grdEmp"); + } + + //榛樿鍒楀 + private void mrlk_Click(object sender, EventArgs e) + { + DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); + DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub"); + DBUtility.Xt_BaseBillFun.DefaultGridView(grdEmp, this.Name + "grdEmp"); + } + + #endregion + + + #region 杩斿洖婧愬崟淇℃伅 + + private void xd_Click(object sender, EventArgs e) + { + + } + + + private void Display(string SourceBillType, Int64 HSourceBillInterID, Int64 HSourceBillEntryID) + { + DataSet Ds; + //鐢熶骇璁㈠崟 + if (SourceBillType == "鐢熶骇璁㈠崟") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IFCLD_ICMOList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IFCLD_ICMOList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + //鏀舵枡閫氱煡鍗� + if (SourceBillType == "鏀舵枡閫氱煡鍗�") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IF_POInStockList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + //鐢熶骇姹囨姤鍗� + if (SourceBillType == "鐢熶骇姹囨姤鍗�") + { + //寰楀埌淇℃伅 + Ds = oWeb.getDataSetBySQL("select * from h_v_IF_ICMOReportBillList where hmainid=" + HSourceBillInterID + " and hsubid=" + HSourceBillEntryID, "h_v_IF_POInStockList", ref DBUtility.ClsPub.sExeReturnInfo); + //鍐欏叆淇℃伅 + Sub_WriteInForm(Ds.Tables[0], 0); + } + } + + //鏍规嵁TABLE鍐欏叆鐣岄潰 + private void Sub_WriteInForm(DataTable oTable, int i) + { + try + { + txtHSourceBillNo.Text = oTable.Rows[0]["鍗曟嵁鍙�"].ToString(); + txtHMaterNumber.Text = oTable.Rows[0]["鐗╂枡浠g爜"].ToString(); + txtHOldMaterNumber.Text = oTable.Rows[0]["鏃х墿鏂欑紪鐮�"].ToString(); + txtHMaterNumber.Tag = oTable.Rows[0]["HMaterID"].ToString(); + txtHMaterName.Text = oTable.Rows[0]["鐗╂枡鍚嶇О"].ToString(); + txtHMaterName.Tag = oTable.Rows[0]["HMaterID"].ToString(); + txtHMaterModel.Text = oTable.Rows[0]["瑙勬牸鍨嬪彿"].ToString(); + txtHUnitName.Text = oTable.Rows[0]["璁¢噺鍗曚綅"].ToString(); + txtHUnitName.Tag = oTable.Rows[0]["HUnitID"].ToString(); + txtHBatchNo.Text = oTable.Rows[0]["鎵规"].ToString(); + txtHSumQty.Text = DBUtility.ClsPub.isDoule(oTable.Rows[0]["鏁伴噺"].ToString(), 1); + txtHRelationQty.Text = oTable.Rows[0]["宸茬敓鎴愭潯鐮佹暟閲�"].ToString(); + txtHSYQty.Text = oTable.Rows[0]["鏈敓鎴愭潯鐮佹暟閲�"].ToString(); + txtHKSQty.Text = lblHNowQty.Text; + txtHDQQty.Text = lblHNowQty.Text; + if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text)>0) + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); + } + else + { + txtHSJQty.Text = "0"; + } + DisplayMain(); + //DisplaySub(); + } + catch(Exception e) + { + MessageBox.Show("璇诲彇澶辫触锛�" + e.Message); + } + } + + + private void DisplayMain() + { + DataSet DSet; + string sSql = ""; + string sWhere = ""; + //杩囨护鏉′欢 + sSql = " exec h_p_Sc_ICMOReportToBarCode_All '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); + // + DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_All", ref DBUtility.ClsPub.sExeReturnInfo); + //鐢熸垚棣栬鏍囬 + if (DSet == null) + { + MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); + return; + } + // + if (DSet.Tables[0].Rows.Count>0) + { + grdMain.DataSource = DSet.Tables[0].DefaultView; + } + //鍐荤粨 + int FrCol = DBUtility.ClsPub.isInt(0); + string s = "鏄�"; + ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol); + //鐢荤嚎 + //Total(); + /////////////////////////////////////////// + if (DSet.Tables[1].Rows.Count > 0) + { + grdSub.DataSource = DSet.Tables[1].DefaultView; + } + //鍐荤粨 + ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); + ///////////////////////////// + txtHRelationQty.Text = DBUtility.ClsPub.isDoule(DSet.Tables[2].Rows[0]["鍏宠仈鏁伴噺"], 1); + if(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text)>=0) + { + txtHSYQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHSumQty.Text) - DBUtility.ClsPub.isDoule(txtHRelationQty.Text), 1); + } + else + { + txtHSYQty.Text = "0"; + } + ////////////////////////// + } + + private void DisplaySub() + { + DataSet DSet; + string sSql = ""; + string sWhere = ""; + //杩囨护鏉′欢 + sSql = " exec h_p_Sc_ICMOReportToBarCode_Sub '" + HSourceBillTypeID + "'," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString(); + + // + DSet = oWeb.getDataSetBySQL(sSql, "h_p_Sc_ICMOReportToBarCode_Sub", ref DBUtility.ClsPub.sExeReturnInfo); + //鐢熸垚棣栬鏍囬 + if (DSet == null) + { + MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo); + return; + } + // + grdSub.DataSource = DSet.Tables[0].DefaultView; + + + //鍐荤粨 + int FrCol = DBUtility.ClsPub.isInt(0); + string s = "鏄�"; + ClsPub1.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol); + //鐢荤嚎 + //Total(); + } + + + #endregion + + + #region //鎵撳嵃璁剧疆 + + GridppReport Report; + string sBarCode = ""; + + //棰勮 + int CurRows = 0; + + + + + + + + #endregion + + + #region 鐣岄潰鎺т欢澶勭悊 + + private void cmdHDeptID_Click(object sender, EventArgs e) + { + SCM.ClsIF_Department_View oDept = new SCM.ClsIF_Department_View(); + string sWhere = ""; + if (oDept.RefreshView(sWhere)) + { + this.txtHDeptID.Text = oDept.oModel.HName; + this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString(); + } + else + { + this.txtHDeptID.Text = ""; + } + } + + private void txtHDeptID_TextChanged(object sender, EventArgs e) + { + BLL.ClsPub_BLL.Sub_ClearText(txtHDeptID); + } + + #endregion + + + //閫夋嫨婧愬崟 + private void cmdHSourceBillNo_Click(object sender, EventArgs e) + { + Gy_SourceBillList_Touch oGy_SourceBillList_Touch = new Gy_SourceBillList_Touch(); + oGy_SourceBillList_Touch.HSourceBillType = HSourceBillType;//绫诲瀷鍚嶇О + oGy_SourceBillList_Touch.ShowDialog(); + if (oGy_SourceBillList_Touch.OKTag == 1) + { + //鏍规嵁閫変腑鐨勬簮鍗曞唴鐮佸拰瀛愬唴鐮侊紝杩斿洖鐩稿簲淇℃伅 + HSourceEntryID = oGy_SourceBillList_Touch.HSelEntryID; + HSourceInterID = oGy_SourceBillList_Touch.HSelInterID; + HSourceBillTypeID = oGy_SourceBillList_Touch.HSourceBillTypeID; + HSourceBillNo = oGy_SourceBillList_Touch.HSourceBillNo; + Display(HSourceBillType, oGy_SourceBillList_Touch.HSelInterID, oGy_SourceBillList_Touch.HSelEntryID); + } + else + { + HSourceEntryID = 0; + HSourceInterID = 0; + HSourceBillTypeID = ""; + HSourceBillNo = ""; + } + } + + // + private void cmdCancel_Click(object sender, EventArgs e) + { + CloseCom(); + this.Close(); + } + + private void label19_Click(object sender, EventArgs e) + { + + } + + public bool SaveBill(string sType) + { + try + { + int LSHlen = 2; //娴佹按鍙烽暱搴� + int SumLen = 10; //鎬婚暱搴� + string TM = ""; //鏉$爜 + string HNumber = ""; //鐗╂枡浠g爜 + double HSumQty = 0; //浜у搧鏁伴噺 + double HMinQty = 0; //鏈�灏忓寘瑁呮暟 + int HBQty = 0; //绠辨暟 + double HQty = 0; //鏁伴噺 + string WeiShu = ""; //灏炬暟 + int LSH = 0; //娴佹按鍙� + string LSH2 = ""; //娴佹按鍙疯浆鎹㈡垚瀛楃 + string sDate = ""; //鏃ユ湡 + string sYear = ""; //骞� + string sPeriod = ""; //鏈� + string sDay = ""; //鏃� + string HBatchNo = ""; //鎵规 + int k = 0; + int n = 0; //鍚屼竴鎵圭敓鎴愭潯鐮佷腑鐨勭鍑犳潯 + string sTMNumber = ""; //鏉$爜鑷畾涔夊墠缂� + DataSet Ds; + // + string HWei = ""; //灏炬暟 + HBarCode = ""; + string HBarCodeType = ""; + Int64 HMaterID = 0; + Int64 HAuxPropID = 0; + Int64 HUnitID = 0; + double HQty2 = 0; + string HBatchNo2 = ""; + Int64 HSupID = 0; + Int64 HGroupID = 0; + int HPrintQty = 0; + Int64 HBarcodeNo = 0; //鎵樺彿 + Int64 HBarcodeQtys = 0; //鎬绘墭鏁� + Int64 HDeptID = 0; + Int64 HWhID = 0; + Int64 HSPID = 0; + string HRemark = ""; + string HMaterName = ""; + string HMaterModel = ""; + string HPinfan = ""; + string HMTONo = ""; + Int64 HCusID = 0; + string HCusType = ""; + DateTime HEndDate; + string HWorkLineName = ""; + DateTime HBeginDate; + string HSeOrderBillNo = ""; + string HJiaYe2 = ""; + string HPressModel = ""; + string HCusModel = ""; + string HMaterialModel = ""; + string HColor = ""; + string HLogo = ""; + string HPackageSize = ""; + double HMaterialJQty = 0; + double HMaterialMQty = 0; + string HCustomBatchNo = ""; + string HGBBarCode = ""; + string POOrderBillNo = ""; + // + cmdHSaveBill.Enabled = false; + //鍒ゆ柇鏄惁瀛樺湪 婧愬崟淇℃伅锛� + if (HSourceInterID <= 0 || HSourceEntryID <= 0 || DBUtility.ClsPub.isLong(txtHMaterName.Tag) <= 0 || DBUtility.ClsPub.isLong(txtHUnitName.Tag) <= 0)//鍒ゆ柇鏄惁鏈夋簮鍗� + { + MessageBox.Show("娌℃湁閫夊崟锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) >= 0) + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + else + { + if (MessageBox.Show("褰撳墠绫虫暟灏忎簬寮�濮嬬背鏁帮紝鏄惁纭畾瑕佹竻闆跺紑濮嬬背鏁�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) + { + txtHKSQty.Text = "0"; + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + } + if (DBUtility.ClsPub.isDoule(txtHSJQty.Text) <= 0) + { + MessageBox.Show("褰撳墠鏁伴噺涓嶈兘灏忎簬绛変簬0锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + //if (DBUtility.ClsPub.isDoule(txtHSYQty.Text) <= 0) + //{ + // MessageBox.Show("鍓╀綑鏁伴噺宸茬粡涓�0锛屼笉鑳藉湪瑁佸垏锛�"); + // cmdHSaveBill.Enabled = true; + // return false; + //} + if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0 || DBUtility.ClsPub.isLong(txtHEmpID2.Tag) == 0 ) + { + MessageBox.Show("鑱屽憳1鎴栬�呰亴鍛�2娌℃湁閫夋嫨锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + if (DBUtility.ClsPub.isLong(txtHGroupID.Tag) == 0 ) + { + MessageBox.Show("鐝粍娌℃湁閫夋嫨锛�"); + cmdHSaveBill.Enabled = true; + return false; + } + + + //鏍规嵁婧愬崟 鐢熸垚鏉″舰鐮� 骞朵繚瀛樺鏁版嵁搴� + HNumber = DBUtility.ClsPub.isStrNull(txtHMaterName.Tag); + HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text); + sDate = dtpHDate.Value.ToShortDateString(); + 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(); +>>>>>>> parent of 8ea5757 (nothing) sDay = sDay.Substring(sDay.Length - 2, 2); //鏉$爜鍓嶇紑 = 缁勭粐浠g爜 + 鐗╂枡鍐呯爜 + 骞� + 鏈� + 鏃� @@ -557,23 +1651,23 @@ { sTMNumber = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text); } - //sTMNumber = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text); - - Ds = oWeb.getDataSetBySQL("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo", ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰彇鏈�澶ф祦姘村彿 - LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]); - - // - HQty = DBUtility.ClsPub.isDoule(txtHSJQty.Text); - // - string sSQLNoMul = " exec h_p_WMS_SetMaxNo '" + sTMNumber + "' "; - oWeb.getRunProc(sSQLNoMul, ref DBUtility.ClsPub.sExeReturnInfo); - // - HWei = ""; - LSH = LSH + 1; - LSH2 = LSH.ToString(); - while (LSH2.Length < LSHlen) //濡傛灉娴佹按鍙峰皬浜�6浣嶆暟鍓嶉潰琛�0 - { - LSH2 = "0" + LSH2; + //sTMNumber = HNumber + ";" + DBUtility.ClsPub.isStrNull(txtHBatchNo.Text); + + Ds = oWeb.getDataSetBySQL("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo", ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰彇鏈�澶ф祦姘村彿 + LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]); + + // + HQty = DBUtility.ClsPub.isDoule(txtHSJQty.Text); + // + string sSQLNoMul = " exec h_p_WMS_SetMaxNo '" + sTMNumber + "' "; + oWeb.getRunProc(sSQLNoMul, ref DBUtility.ClsPub.sExeReturnInfo); + // + HWei = ""; + LSH = LSH + 1; + LSH2 = LSH.ToString(); + while (LSH2.Length < LSHlen) //濡傛灉娴佹按鍙峰皬浜�6浣嶆暟鍓嶉潰琛�0 + { + LSH2 = "0" + LSH2; } //鏉$爜缂栧彿 = 鏉$爜鍓嶇紑 + 娴佹按鍙� @@ -591,14 +1685,14 @@ { TM = sTMNumberNew + "-" + LSH2; } - //TM = sTMNumber + "-" + LSH2; - - HBarCode = TM; - HBarCodeType = "鍞竴鏉$爜"; - - HMaterID = DBUtility.ClsPub.isLong(txtHMaterName.Tag); - HAuxPropID = 0; - HUnitID = DBUtility.ClsPub.isLong(txtHUnitName.Tag); + //TM = sTMNumber + "-" + LSH2; + + HBarCode = TM; + HBarCodeType = "鍞竴鏉$爜"; + + HMaterID = DBUtility.ClsPub.isLong(txtHMaterName.Tag); + HAuxPropID = 0; + HUnitID = DBUtility.ClsPub.isLong(txtHUnitName.Tag); HQty2 = HQty; //HBatchNo2 = HBatchNo; //if (HSourceBillType != "鐢熶骇璁㈠崟") @@ -619,925 +1713,925 @@ HBatchNo2 = HBatchNo + "-" + LSH2; } //} - //HSourceBillType = HSourceBillTypeID; - HBarcodeQtys = 0; - HBarcodeNo = 1; - HSupID = 0; - HDeptID = 0; - HWhID = 0; - HSPID = 0; - if (sType == "SaveDown") - { - HRemark = "浜岀瓑鍝�"; - } - else if (sType == "Sample") - { - HRemark = "鏍锋湰绾�"; - } - else - { - HRemark = ""; - } - HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text); - HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text); - HPinfan = ""; - HMTONo = ""; - HCusID = 0; - HCusType = ""; - HEndDate = dtpHDate.Value; - HWorkLineName = DBUtility.ClsPub.isStrNull(txtHEmpID.Text) + ";" + DBUtility.ClsPub.isStrNull(txtHEmpID2.Text) + ";" + DBUtility.ClsPub.isStrNull(txtHEmpID3.Text); - HBeginDate = dtpHDate.Value; - HSeOrderBillNo = ""; - HGroupID = DBUtility.ClsPub.isLong(txtHGroupID.Tag); - HJiaYe2 = DBUtility.ClsPub.isLong(txtHEmpID.Tag).ToString() + ";" + DBUtility.ClsPub.isLong(txtHEmpID2.Tag).ToString() + ";" + DBUtility.ClsPub.isLong(txtHEmpID3.Tag).ToString(); - HPressModel = ""; - HCusModel = ""; - HMaterialModel = ""; - HColor = ""; - HLogo = ""; - HPackageSize = ""; - HMaterialJQty = 0; - HMaterialMQty = 0; - HCustomBatchNo = ""; - HGBBarCode = ""; - POOrderBillNo = ""; - string sSQLMul = " 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,HJiaYe " + - ",HPressModel,HCusModel,HMaterialModel,HColor,HBarCodeDate " + - ",HLogo,HPackageSize,HMaterialJQty,HMaterialMQty,HCustomBatchNo " + - ",HSTOCKORGID,HOWNERID,HBeginDate,HSeOrderBillNo,HGBBarCode " + - ",POOrderBillNo,HSourceID " + - ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HBadReasonList,HProdLev " + - ") values (" - + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString() - + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString() - + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillTypeID + "','" + HWei + "'" - + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'" - + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + HJiaYe2 + "'" - + ",'" + HPressModel + "','" + HCusModel + "','" + HMaterialModel + "','" + HColor + "','" + sDate + "'" - + ",'" + HLogo + "','" + HPackageSize + "'," + HMaterialJQty.ToString() + "," + HMaterialMQty.ToString() + ",'" + HCustomBatchNo + "'" - + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HBeginDate.ToShortDateString() + "','" + HSeOrderBillNo + "','" + HGBBarCode + "'" - + ",'" + POOrderBillNo + "'" + "," + DBUtility.ClsPub.isLong(txtHSourceID.Tag) - + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','"+ txtHReasonList.Text + "','"+ HRemark + "')"; - oWeb.getRunProc(sSQLMul, ref DBUtility.ClsPub.sExeReturnInfo); - - - //鍒锋柊鐣岄潰 - DisplayMain(); - //DisplaySub(); - //鏍规嵁鐣岄潰閫夋嫨鎵撳嵃妯℃澘锛屾墦鍗版潯褰㈢爜 - Sub_SetReport(cmbFQMB.Text); - if (DBUtility.ClsPub.CurUserName.ToLower() == "admin") - { - Report.PrintPreview(false); - } - else - { - Report.Print(false); - } - - Thread.Sleep(500); - - if (HSourceBillType != "鐢熶骇姹囨姤鍗�") - { - txtHKSQty.Text = "0"; - } - - cmdHSaveBill.Enabled = true; - return true; - } - catch (Exception e1) - { - MessageBox.Show("淇濆瓨澶辫触锛�" + e1.Message); - cmdHSaveBill.Enabled = true; - return false; - } - } - - public string HOrgNumber = "1001"; - public Int64 HOrgID = 1; - public string HBarCode = ""; - - //淇濆瓨 骞剁敓鎴愭墦鍗版潯鐮� - private void cmdHSaveBill_Click(object sender, EventArgs e) - { - SaveBill(""); - } - - - private void Sub_SetReport(string sOpenTmp) - { - //鍒ゆ柇琛屾暟 - - Report = new GridppReport(); - Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . - Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord); - Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); - //Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd); - } - - - private void Sub_SetReportList(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(ReportBeforePostRecordList); - Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTableList); - //Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd); - } - - //濉叆鍗曟嵁琛ㄥご淇℃伅 - private void ReportBeforePostRecord()// - { - try - { - Report.FieldByName("鐗╂枡浠g爜").AsString = ClsPub.isStrNull(txtHMaterNumber.Text); - Report.FieldByName("鐗╂枡鍚嶇О").AsString = ClsPub.isStrNull(txtHMaterName.Text); - Report.FieldByName("瑙勬牸鍨嬪彿").AsString = ClsPub.isStrNull(txtHMaterModel.Text); - Report.FieldByName("鏉$爜缂栧彿").AsString = HBarCode; - Report.FieldByName("鏁伴噺").AsString = ClsPub.isStrNull(txtHSJQty.Text); - Report.FieldByName("鐝粍").AsString = ClsPub.isStrNull(txtHGroupID.Text); - Report.FieldByName("缁勫憳").AsString = ClsPub.isStrNull(txtHEmpID.Text) + ";" + ClsPub.isStrNull(txtHEmpID2.Text) + ";" + ClsPub.isStrNull(txtHEmpID3.Text); - Report.FieldByName("鏁伴噺").AsString = ClsPub.isStrNull(txtHSJQty.Text); - Report.FieldByName("鏃х墿鏂欑紪鐮�").AsString = ClsPub.isStrNull(txtHOldMaterNumber.Text); - //Report.FieldByName("婧愬崟鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); - //Report.FieldByName("閿�鍞鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value); - //Report.FieldByName("鐢熶骇杞﹂棿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value); - //Report.FieldByName("澶囨敞").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value); - } - catch (Exception e) - { - MessageBox.Show("鎵撳嵃澶辫触!琛ㄥご锛�" + e.Message); - } - } - - private void ReportFetchRecordByDataTable() - { - try - { - DataTable ds = new DataTable(); - BLL.Utility.FillRecordToReport_FstRow(Report, grdMain, ds, 0); - } - catch (Exception e) - { - MessageBox.Show("鎵撳嵃澶辫触!琛ㄤ綋锛�" + e.Message); - } - } - - //濉叆鍗曟嵁琛ㄥご淇℃伅 - private void ReportBeforePostRecordList()// - { - try - { - //Report.FieldByName("鐗╂枡浠g爜").AsString = ClsPub.isStrNull(txtHMaterNumber.Text); - //Report.FieldByName("鐗╂枡鍚嶇О").AsString = ClsPub.isStrNull(txtHMaterName.Text); - //Report.FieldByName("瑙勬牸鍨嬪彿").AsString = ClsPub.isStrNull(txtHMaterModel.Text); - //Report.FieldByName("鏉$爜缂栧彿").AsString = HBarCode; - //Report.FieldByName("鏁伴噺").AsString = ClsPub.isStrNull(txtHSJQty.Text); - //Report.FieldByName("婧愬崟鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); - //Report.FieldByName("閿�鍞鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value); - //Report.FieldByName("鐢熶骇杞﹂棿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value); - //Report.FieldByName("澶囨敞").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value); - } - catch (Exception e) - { - MessageBox.Show("鎵撳嵃澶辫触!琛ㄥご锛�" + e.Message); - } - } - - private void ReportFetchRecordByDataTableList() - { - try - { - DataTable ds = new DataTable(); - SCM.Utility.FillRecordToReport(Report, grdMain, ds, Fun_GetCol("閫夋嫨")); - } - catch (Exception e) - { - MessageBox.Show("鎵撳嵃澶辫触!琛ㄤ綋锛�" + e.Message); - } - } - - private SerialPort ComDevice = null; - - public void OpenCom() - { - if (!ComDevice.IsOpen) - { - - try - { - ComDevice.PortName = txtPortName.Text; - ComDevice.BaudRate = int.Parse(txtBaudRate.Text); - switch (cmbParity.SelectedItem.ToString()) - { - case "0": - ComDevice.Parity = Parity.None; - break; - case "1": - ComDevice.Parity = Parity.Odd; - break; - case "2": - ComDevice.Parity = Parity.Even; - break; - case "3": - ComDevice.Parity = Parity.Mark; - break; - case "4": - ComDevice.Parity = Parity.Space; - break; - default: - break; - } - - ComDevice.DataBits = int.Parse(txtDataBits.Text); - switch (cmbStopBits.SelectedItem.ToString()) - { - case "0": - ComDevice.StopBits = StopBits.None; - break; - case "1": - ComDevice.StopBits = StopBits.One; - break; - case "2": - ComDevice.StopBits = StopBits.Two; - break; - case "1.5": - ComDevice.StopBits = StopBits.OnePointFive; - break; - default: - break; - } - - ComDevice.Open(); - lblComStatus.Text = "涓插彛鐘舵�侊細寮�鍚�"; - timer3.Enabled = true; - } - catch (Exception ex) - { - MessageBox.Show("鎵撳紑涓插彛澶辫触锛�" + ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - else - { - //try - //{ - // ComDevice.Close(); - // textBox3.Enabled = true; - // textBox4.Enabled = true; - // textBox5.Enabled = true; - // comboBox1.Enabled = true; - // comboBox2.Enabled = true; - // AddContent($"涓插彛宸插叧闂�"); - // button1.Enabled = false; - // btnPush.Text = "寮�鍚覆鍙�"; - //} - //catch (Exception ex) - //{ - // MessageBox.Show(ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); - // AddContent($"涓插彛鍏抽棴澶辫触锛歿ex.Message}"); - // return; - //} - } - } - - private void cmdOpenCom_Click(object sender, EventArgs e) - { - OpenCom(); - } - - private void cmdCloseCom_Click(object sender, EventArgs e) - { - CloseCom(); - } - - public void CloseCom() - { - if (!ComDevice.IsOpen) - { - - } - else - { - try - { - ComDevice.Close(); - lblComStatus.Text = "涓插彛鐘舵�侊細鍏抽棴"; - timer3.Enabled = false; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } - - //璁惧娓呴浂 - private void cmdHSetZero_Click(object sender, EventArgs e) - { - cmdHSetZero.Enabled=false; - byte[] sendData = strToHexByte(txtHSend0.Text); - SendData(sendData); - txtHSJQty.Text = "0"; - txtHDQQty.Text = "0"; - txtHKSQty.Text = "0"; - lblHNowQty.Text = "0"; - lblHRelQty.Text = "0"; - cmdHSetZero.Enabled = true; - } - - /// <summary> - /// 瀛楃涓茶浆鎹�16杩涘埗瀛楄妭鏁扮粍 - /// </summary> - /// <param name="hexString"></param> - /// <returns></returns> - private byte[] strToHexByte(string hexString) - { - hexString = hexString.Replace(" ", ""); - if ((hexString.Length % 2) != 0) - hexString += " "; - byte[] returnBytes = new byte[hexString.Length / 2]; - for (int i = 0; i < returnBytes.Length; i++) - returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Replace(" ", ""), 16); - return returnBytes; - } - - - /// <summary> - /// 鍙戦�佹暟鎹� - /// </summary> - /// <param name="sender"></param> - /// <param name="data"></param> - public bool SendData(byte[] data) - { - if (ComDevice.IsOpen) - { - try - { - ComDevice.Write(data, 0, data.Length);//鍙戦�佹暟鎹� - return true; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - finally - { - //cmdHSetZero.Enabled = true; - } - } - else - { - MessageBox.Show("涓插彛鏈墦寮�", "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - return false; - } - - private void timer3_Tick(object sender, EventArgs e) - { - if (!ComDevice.IsOpen) - { - return; - } - byte[] sendData = strToHexByte(txtHSend.Text); - SendData(sendData); - - } - - /// <summary> - /// 鎺ユ敹鏁版嵁 - /// </summary> - /// <param name="sender"></param> - /// <param name="e"></param> - private void Com_DataReceived(object sender, SerialDataReceivedEventArgs e) - { - //if (!ComDevice.IsOpen) - //{ - // return; - //} - Thread.Sleep(100); - byte[] ReDatas = new byte[ComDevice.BytesToRead]; - ComDevice.Read(ReDatas, 0, ReDatas.Length);//璇诲彇鏁版嵁 - this.AddData(ReDatas);//杈撳嚭鏁版嵁 - } - - - ///// <summary> - ///// 娣诲姞鏁版嵁 - ///// </summary> - ///// <param name="data">瀛楄妭鏁扮粍</param> - //public void AddData(byte[] data) - //{ - // StringBuilder sb = new StringBuilder(); - // for (int i = 0; i < data.Length; i++) - // { - // sb.AppendFormat("{0:x2}" + " ", data[i]); - // } - // string str = sb.ToString().ToUpper() ; - // string[] strArr = str.Split(' '); - // string newStr = string.Empty; - // try - // { - // if (strArr[4] != "00") - // { - // char[] bw = strArr[4].ToCharArray(); - // if(bw[0]=='0') - // { - // newStr = bw[1].ToString(); - // } - // else - // { - // newStr = strArr[4]; - // } - - // } - // if (string.IsNullOrEmpty(newStr)) - // { - // char[] bw = strArr[5].ToCharArray(); - // if (bw[0] == '0') - // { - // newStr = bw[1].ToString(); - // } - // else - // { - // newStr = strArr[5]; - // } - // } - // else - // { - // newStr += strArr[5]; - // } - // if (strArr[6] != "00" && newStr=="00") - // { - // //newStr = $"0.{strArr[6]}"; - // newStr = "0." + strArr[6]; - // } - // if(strArr[6]!="00" && newStr != "00") - // { - // //newStr += $".{strArr[6]}"; - // newStr = newStr + strArr[6]; - - // } - // } - // catch - // { - // newStr = "-1"; - // } - // //灏嗗綋鍓嶆暟 鍘樼背 杞寲涓� 绫� - // double NewQty = DBUtility.ClsPub.isDoule(newStr) / 100.0000; - // if (NewQty <= 0) - // { - // newStr = "0"; - // } - // else - // { - // newStr = DBUtility.ClsPub.isDoule(NewQty, 2); - // } - // // - // lblHNowQty.Text = newStr; //褰撳墠绫虫暟 鏍囩 - // txtHDQQty.Text = newStr; //褰撳墠鏁伴噺 鏂囨湰 - // txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 2); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� - // lblHRelQty.Text = txtHSJQty.Text; - //} - - - /// <summary> - /// 娣诲姞鏁版嵁 - /// </summary> - /// <param name="data">瀛楄妭鏁扮粍</param> - public void AddData(byte[] data) - { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < data.Length; i++) - { - sb.AppendFormat("{0:x2}" + " ", data[i]); - } - var str = sb.ToString().ToUpper().Trim(); - string[] strArr = str.Split(' '); - string newStr = string.Empty; - try - { - if (strArr[4] != "00") - { - char[] bw = strArr[4].ToCharArray(); - if(bw[0]=='0') - { - newStr = bw[1].ToString(); - } - else - { - newStr = strArr[4]; - } - - } - if (string.IsNullOrEmpty(newStr)) - { - char[] bw = strArr[5].ToCharArray(); - if (bw[0] == '0') - { - newStr = bw[1].ToString(); - } - else - { - newStr = strArr[5]; - } - } - else - { - newStr += strArr[5]; - } - if (strArr[6] != "00"&&newStr=="00") - { - //newStr = $"0.{strArr[6]}"; - newStr = "0." + strArr[6]; - } - if(strArr[6]!="00"&&newStr!="00") - { - //newStr += $".{strArr[6]}"; - newStr = newStr + "." + strArr[6]; - } - } - catch - { - newStr = "-1"; - } - - - //灏嗗綋鍓嶆暟 鍘樼背 杞寲涓� 绫� - double NewQty = DBUtility.ClsPub.isDoule(newStr) ; - if (NewQty <= 0) - { - newStr = "0"; - } - else - { - newStr = DBUtility.ClsPub.isDoule(NewQty, 1); - } - // - lblHNowQty.Text = newStr; //褰撳墠绫虫暟 鏍囩 - txtHDQQty.Text = newStr; //褰撳墠鏁伴噺 鏂囨湰 - if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) > 0) - { - txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� - lblHRelQty.Text = txtHSJQty.Text; - } - else - { - txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� - lblHRelQty.Text = txtHSJQty.Text; - } - } - - //鍒犻櫎閫変腑鐨勮鏁� - private void btnFQSH_Click(object sender, EventArgs e) - { - DelRow(); - } - - public void DelRow() - { - //WEBS - //if (!oWeb.getSecurity_Log(ModRightNameEdit, DBUtility.ClsPub.CurUserName, ref DBUtility.ClsPub.sExeReturnInfo)) - //{ - // MessageBox.Show("鎮ㄦ病鏈夊垹闄ゆ潈闄愶紒"); - // return; - //} - DataSet DS; - DataSet DS2; - bool sBool = true; - Int64 lngBillKey = 0; - if (grdMain.CurrentRow == null) - return; - if (MessageBox.Show("纭畾瑕佸垹闄ゆ墍閫夎锛�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) - { - for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++) - { - lngBillKey = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HItemID")].Value); - if (lngBillKey == 0) - return; - try - { - oWeb.getRunProc("Delete from Gy_BarCodeBill where HItemID=" + lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo); - oWeb.getRunProc("insert into System_log values(GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.CurUserName + "','鍒犻櫎鏉$爜锛�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉″舰鐮�")].Value) + "' ,'WMS绯荤粺','','鍒犻櫎')", ref DBUtility.ClsPub.sExeReturnInfo); - - } - catch (Exception e) - { - throw (e); - } - } - } - MessageBox.Show("鍒犻櫎鎴愬姛锛�", "鎻愮ず"); - DisplayMain(); - } - - private void btnFQBD_Click(object sender, EventArgs e) - { - //鏍规嵁鐣岄潰閫夋嫨鎵撳嵃妯℃澘锛屾墦鍗版潯褰㈢爜 - Sub_SetReportList(cmbFQMB.Text); - Report.PrintPreview(false); - Thread.Sleep(500); - } - - private void cmdHSaveInfo_Click(object sender, EventArgs e) - { - ClsIni.WriteIni("COMINFO", "txtPortName", DBUtility.ClsPub.isStrNull(txtPortName.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.isStrNull(txtBaudRate.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "cmbParity", DBUtility.ClsPub.isStrNull(cmbParity.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "txtDataBits", DBUtility.ClsPub.isStrNull(txtDataBits.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.isStrNull(cmbStopBits.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "txtHSend0", DBUtility.ClsPub.isStrNull(txtHSend0.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "txtHSend", DBUtility.ClsPub.isStrNull(txtHSend.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.isStrNull(txtHSourceID.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - ClsIni.WriteIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.isStrNull(txtHSourceID.Tag), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); - } - - private void btnBLHB_Click(object sender, EventArgs e) - { - Gy_BadReasonList oGy_BadReasonList = new Gy_BadReasonList(); - oGy_BadReasonList.ShowDialog(); - if (oGy_BadReasonList.ISOK == 1) - { - txtHReasonList.Text = ""; - txtHReasonList.Text = oGy_BadReasonList.txtHBadReason.Text; - if (SaveBadReasonBill()) - { - MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜鎴愬姛锛�"); - - DisplayMain(); - } - else - { - MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo); - } - } - oGy_BadReasonList = null; - } - - private void cmdSaveAndNext_Click(object sender, EventArgs e) - { - if (SaveBill("Save")) - { - txtHKSQty.Text = txtHDQQty.Text;//缁х画瑁佸垏锛屽皢褰撳墠绫虫暟浣滀负寮�濮嬬背鏁帮紱 - } - } - - private void btnBLBD_Click(object sender, EventArgs e) - { - - } - - private void btnBLSH_Click(object sender, EventArgs e) - { - - } - - private void cmdHWaitList_Click(object sender, EventArgs e) - { - //璺冲嚭璇ヤ骇绾� 鏈鐞嗙殑鍗曟嵁 - Sc_WaitingForCutting_List oSc_WaitingForCutting_List = new Sc_WaitingForCutting_List(); - if (HSourceBillType == "鐢熶骇璁㈠崟") - { - oSc_WaitingForCutting_List.HBillType = "3710"; - } - else if (HSourceBillType == "鐢熶骇姹囨姤鍗�") - { - oSc_WaitingForCutting_List.HBillType = "3711"; - } - else if (HSourceBillType == "鏀舵枡閫氱煡鍗�") - { - oSc_WaitingForCutting_List.HBillType = "1203"; - } - else - { - MessageBox.Show("閿欒鐨勫崟鎹被鍨嬶紒"); - return; - } - - oSc_WaitingForCutting_List.ShowDialog(); - - } - - private bool SaveBadReasonBill() - { - try - { - if (txtHReasonList.Text.Trim() == "") - { - MessageBox.Show("娌℃湁閫夋嫨涓嶈壇鍘熷洜锛�"); - return false; - } - //灏嗛�夋嫨涓嶈壇鍘熷洜鍒嗚В骞朵繚瀛樺叆鏁版嵁搴� - WMSWeb.ClsQC_NoPassProdCheckBillMain oQC_NoPassProdCheckBillMain = new WMSWeb.ClsQC_NoPassProdCheckBillMain(); - oQC_NoPassProdCheckBillMain.HDate = DateTime.Today; - oQC_NoPassProdCheckBillMain.HSourceID = DBUtility.ClsPub.isLong(txtHSourceID.Tag); - oQC_NoPassProdCheckBillMain.HMaterID = DBUtility.ClsPub.isLong(txtHMaterNumber.Tag); - oQC_NoPassProdCheckBillMain.HProcID = DBUtility.ClsPub.isLong(0); - oQC_NoPassProdCheckBillMain.HWorkCenterID = DBUtility.ClsPub.isLong(0); - oQC_NoPassProdCheckBillMain.HICMOInterID = 0; - oQC_NoPassProdCheckBillMain.HICMOBillNo = ""; - oQC_NoPassProdCheckBillMain.HInStockQty = 0; - oQC_NoPassProdCheckBillMain.HCheckQty = 0; - oQC_NoPassProdCheckBillMain.HRightQty = 0; - oQC_NoPassProdCheckBillMain.HBadQty = DBUtility.ClsPub.isDoule(txtHDQQty.Text); - oQC_NoPassProdCheckBillMain.HPlanQty = 0; - oQC_NoPassProdCheckBillMain.HBadPNL = 0; - oQC_NoPassProdCheckBillMain.HPlanPNL = 0; - oQC_NoPassProdCheckBillMain.HFirstCheckEmp = 0; - oQC_NoPassProdCheckBillMain.HCheckerResult = txtHReasonList.Text; - oQC_NoPassProdCheckBillMain.HNote = "鍦ㄧ嚎妫�楠�"; - oQC_NoPassProdCheckBillMain.HProcExchInterID = HSourceInterID;//婧愬崟涓诲唴鐮� - oQC_NoPassProdCheckBillMain.HProcExchEntryID = HSourceEntryID;//婧愬崟瀛愬唴鐮� - oQC_NoPassProdCheckBillMain.HProcExchBillNo = HSourceBillTypeID;//婧愬崟绫诲瀷 - oQC_NoPassProdCheckBillMain.HMainSourceInterID = 0; - oQC_NoPassProdCheckBillMain.HGroupName = ""; - oQC_NoPassProdCheckBillMain.HOrderProcNo = ""; - oQC_NoPassProdCheckBillMain.HProcExchQty = 0; - oQC_NoPassProdCheckBillMain.HBarCode = HBarCode; - if (oWeb.set_SaveNoPassProdCheckBill_New(oQC_NoPassProdCheckBillMain, HSourceBillTypeID, txtHReasonList.Text.Trim(), ref DBUtility.ClsPub.sExeReturnInfo)) - { - txtHReasonList.Text = ""; - return true; - } - txtHReasonList.Text = ""; - return false; - } - catch(Exception e1) - { - MessageBox.Show(e1.Message); - return false; - } - } - - private void cmdHSourceID_Click(object sender, EventArgs e) - { - SCM.ClsIF_Source_View oSource = new SCM.ClsIF_Source_View(); - string sWhere = ""; - if (oSource.RefreshView(sWhere)) - { - this.txtHSourceID.Text = oSource.oModel.HName; - this.txtHSourceID.Tag = oSource.oModel.HItemID.ToString(); - } - else - { - this.txtHSourceID.Text = ""; - } - } - - private void cmdSaveAndDown_Click(object sender, EventArgs e) - { - Gy_BadReasonList oGy_BadReasonList = new Gy_BadReasonList(); - oGy_BadReasonList.ShowDialog(); - if (oGy_BadReasonList.ISOK == 1) - { - txtHReasonList.Text = ""; - txtHReasonList.Text = oGy_BadReasonList.txtHBadReason.Text; + //HSourceBillType = HSourceBillTypeID; + HBarcodeQtys = 0; + HBarcodeNo = 1; + HSupID = 0; + HDeptID = 0; + HWhID = 0; + HSPID = 0; + if (sType == "SaveDown") + { + HRemark = "浜岀瓑鍝�"; + } + else if (sType == "Sample") + { + HRemark = "鏍锋湰绾�"; + } + else + { + HRemark = ""; + } + HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text); + HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text); + HPinfan = ""; + HMTONo = ""; + HCusID = 0; + HCusType = ""; + HEndDate = dtpHDate.Value; + HWorkLineName = DBUtility.ClsPub.isStrNull(txtHEmpID.Text) + ";" + DBUtility.ClsPub.isStrNull(txtHEmpID2.Text) + ";" + DBUtility.ClsPub.isStrNull(txtHEmpID3.Text); + HBeginDate = dtpHDate.Value; + HSeOrderBillNo = ""; + HGroupID = DBUtility.ClsPub.isLong(txtHGroupID.Tag); + HJiaYe2 = DBUtility.ClsPub.isLong(txtHEmpID.Tag).ToString() + ";" + DBUtility.ClsPub.isLong(txtHEmpID2.Tag).ToString() + ";" + DBUtility.ClsPub.isLong(txtHEmpID3.Tag).ToString(); + HPressModel = ""; + HCusModel = ""; + HMaterialModel = ""; + HColor = ""; + HLogo = ""; + HPackageSize = ""; + HMaterialJQty = 0; + HMaterialMQty = 0; + HCustomBatchNo = ""; + HGBBarCode = ""; + POOrderBillNo = ""; + string sSQLMul = " 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,HJiaYe " + + ",HPressModel,HCusModel,HMaterialModel,HColor,HBarCodeDate " + + ",HLogo,HPackageSize,HMaterialJQty,HMaterialMQty,HCustomBatchNo " + + ",HSTOCKORGID,HOWNERID,HBeginDate,HSeOrderBillNo,HGBBarCode " + + ",POOrderBillNo,HSourceID " + + ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HBadReasonList,HProdLev " + + ") values (" + + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString() + + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString() + + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillTypeID + "','" + HWei + "'" + + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'" + + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + HJiaYe2 + "'" + + ",'" + HPressModel + "','" + HCusModel + "','" + HMaterialModel + "','" + HColor + "','" + sDate + "'" + + ",'" + HLogo + "','" + HPackageSize + "'," + HMaterialJQty.ToString() + "," + HMaterialMQty.ToString() + ",'" + HCustomBatchNo + "'" + + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HBeginDate.ToShortDateString() + "','" + HSeOrderBillNo + "','" + HGBBarCode + "'" + + ",'" + POOrderBillNo + "'" + "," + DBUtility.ClsPub.isLong(txtHSourceID.Tag) + + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','"+ txtHReasonList.Text + "','"+ HRemark + "')"; + oWeb.getRunProc(sSQLMul, ref DBUtility.ClsPub.sExeReturnInfo); + + + //鍒锋柊鐣岄潰 + DisplayMain(); + //DisplaySub(); + //鏍规嵁鐣岄潰閫夋嫨鎵撳嵃妯℃澘锛屾墦鍗版潯褰㈢爜 + Sub_SetReport(cmbFQMB.Text); + if (DBUtility.ClsPub.CurUserName.ToLower() == "admin") + { + Report.PrintPreview(false); + } + else + { + Report.Print(false); + } + + Thread.Sleep(500); + + if (HSourceBillType != "鐢熶骇姹囨姤鍗�") + { + txtHKSQty.Text = "0"; + } + + cmdHSaveBill.Enabled = true; + return true; + } + catch (Exception e1) + { + MessageBox.Show("淇濆瓨澶辫触锛�" + e1.Message); + cmdHSaveBill.Enabled = true; + return false; + } + } + + public string HOrgNumber = "1001"; + public Int64 HOrgID = 1; + public string HBarCode = ""; + + //淇濆瓨 骞剁敓鎴愭墦鍗版潯鐮� + private void cmdHSaveBill_Click(object sender, EventArgs e) + { + SaveBill(""); + } + + + private void Sub_SetReport(string sOpenTmp) + { + //鍒ゆ柇琛屾暟 + + Report = new GridppReport(); + Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here . + Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord); + Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); + //Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd); + } + + + private void Sub_SetReportList(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(ReportBeforePostRecordList); + Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTableList); + //Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd); + } + + //濉叆鍗曟嵁琛ㄥご淇℃伅 + private void ReportBeforePostRecord()// + { + try + { + Report.FieldByName("鐗╂枡浠g爜").AsString = ClsPub.isStrNull(txtHMaterNumber.Text); + Report.FieldByName("鐗╂枡鍚嶇О").AsString = ClsPub.isStrNull(txtHMaterName.Text); + Report.FieldByName("瑙勬牸鍨嬪彿").AsString = ClsPub.isStrNull(txtHMaterModel.Text); + Report.FieldByName("鏉$爜缂栧彿").AsString = HBarCode; + Report.FieldByName("鏁伴噺").AsString = ClsPub.isStrNull(txtHSJQty.Text); + Report.FieldByName("鐝粍").AsString = ClsPub.isStrNull(txtHGroupID.Text); + Report.FieldByName("缁勫憳").AsString = ClsPub.isStrNull(txtHEmpID.Text) + ";" + ClsPub.isStrNull(txtHEmpID2.Text) + ";" + ClsPub.isStrNull(txtHEmpID3.Text); + Report.FieldByName("鏁伴噺").AsString = ClsPub.isStrNull(txtHSJQty.Text); + Report.FieldByName("鏃х墿鏂欑紪鐮�").AsString = ClsPub.isStrNull(txtHOldMaterNumber.Text); + //Report.FieldByName("婧愬崟鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); + //Report.FieldByName("閿�鍞鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value); + //Report.FieldByName("鐢熶骇杞﹂棿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value); + //Report.FieldByName("澶囨敞").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value); + } + catch (Exception e) + { + MessageBox.Show("鎵撳嵃澶辫触!琛ㄥご锛�" + e.Message); + } + } + + private void ReportFetchRecordByDataTable() + { + try + { + DataTable ds = new DataTable(); + BLL.Utility.FillRecordToReport_FstRow(Report, grdMain, ds, 0); + } + catch (Exception e) + { + MessageBox.Show("鎵撳嵃澶辫触!琛ㄤ綋锛�" + e.Message); + } + } + + //濉叆鍗曟嵁琛ㄥご淇℃伅 + private void ReportBeforePostRecordList()// + { + try + { + //Report.FieldByName("鐗╂枡浠g爜").AsString = ClsPub.isStrNull(txtHMaterNumber.Text); + //Report.FieldByName("鐗╂枡鍚嶇О").AsString = ClsPub.isStrNull(txtHMaterName.Text); + //Report.FieldByName("瑙勬牸鍨嬪彿").AsString = ClsPub.isStrNull(txtHMaterModel.Text); + //Report.FieldByName("鏉$爜缂栧彿").AsString = HBarCode; + //Report.FieldByName("鏁伴噺").AsString = ClsPub.isStrNull(txtHSJQty.Text); + //Report.FieldByName("婧愬崟鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSourceBillNoCol].Value); + //Report.FieldByName("閿�鍞鍗曞彿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HSeOrderBillNo2Col].Value); + //Report.FieldByName("鐢熶骇杞﹂棿").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HDeptName2Col].Value); + //Report.FieldByName("澶囨敞").AsString = ClsPub.isStrNull(grdSub.Rows[CurRows].Cells[HRemark2Col].Value); + } + catch (Exception e) + { + MessageBox.Show("鎵撳嵃澶辫触!琛ㄥご锛�" + e.Message); + } + } + + private void ReportFetchRecordByDataTableList() + { + try + { + DataTable ds = new DataTable(); + SCM.Utility.FillRecordToReport(Report, grdMain, ds, Fun_GetCol("閫夋嫨")); + } + catch (Exception e) + { + MessageBox.Show("鎵撳嵃澶辫触!琛ㄤ綋锛�" + e.Message); + } + } + + private SerialPort ComDevice = null; + + public void OpenCom() + { + if (!ComDevice.IsOpen) + { + + try + { + ComDevice.PortName = txtPortName.Text; + ComDevice.BaudRate = int.Parse(txtBaudRate.Text); + switch (cmbParity.SelectedItem.ToString()) + { + case "0": + ComDevice.Parity = Parity.None; + break; + case "1": + ComDevice.Parity = Parity.Odd; + break; + case "2": + ComDevice.Parity = Parity.Even; + break; + case "3": + ComDevice.Parity = Parity.Mark; + break; + case "4": + ComDevice.Parity = Parity.Space; + break; + default: + break; + } + + ComDevice.DataBits = int.Parse(txtDataBits.Text); + switch (cmbStopBits.SelectedItem.ToString()) + { + case "0": + ComDevice.StopBits = StopBits.None; + break; + case "1": + ComDevice.StopBits = StopBits.One; + break; + case "2": + ComDevice.StopBits = StopBits.Two; + break; + case "1.5": + ComDevice.StopBits = StopBits.OnePointFive; + break; + default: + break; + } + + ComDevice.Open(); + lblComStatus.Text = "涓插彛鐘舵�侊細寮�鍚�"; + timer3.Enabled = true; + } + catch (Exception ex) + { + MessageBox.Show("鎵撳紑涓插彛澶辫触锛�" + ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + else + { + //try + //{ + // ComDevice.Close(); + // textBox3.Enabled = true; + // textBox4.Enabled = true; + // textBox5.Enabled = true; + // comboBox1.Enabled = true; + // comboBox2.Enabled = true; + // AddContent($"涓插彛宸插叧闂�"); + // button1.Enabled = false; + // btnPush.Text = "寮�鍚覆鍙�"; + //} + //catch (Exception ex) + //{ + // MessageBox.Show(ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); + // AddContent($"涓插彛鍏抽棴澶辫触锛歿ex.Message}"); + // return; + //} + } + } + + private void cmdOpenCom_Click(object sender, EventArgs e) + { + OpenCom(); + } + + private void cmdCloseCom_Click(object sender, EventArgs e) + { + CloseCom(); + } + + public void CloseCom() + { + if (!ComDevice.IsOpen) + { + + } + else + { + try + { + ComDevice.Close(); + lblComStatus.Text = "涓插彛鐘舵�侊細鍏抽棴"; + timer3.Enabled = false; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + //璁惧娓呴浂 + private void cmdHSetZero_Click(object sender, EventArgs e) + { + cmdHSetZero.Enabled=false; + byte[] sendData = strToHexByte(txtHSend0.Text); + SendData(sendData); + txtHSJQty.Text = "0"; + txtHDQQty.Text = "0"; + txtHKSQty.Text = "0"; + lblHNowQty.Text = "0"; + lblHRelQty.Text = "0"; + cmdHSetZero.Enabled = true; + } + + /// <summary> + /// 瀛楃涓茶浆鎹�16杩涘埗瀛楄妭鏁扮粍 + /// </summary> + /// <param name="hexString"></param> + /// <returns></returns> + private byte[] strToHexByte(string hexString) + { + hexString = hexString.Replace(" ", ""); + if ((hexString.Length % 2) != 0) + hexString += " "; + byte[] returnBytes = new byte[hexString.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Replace(" ", ""), 16); + return returnBytes; + } + + + /// <summary> + /// 鍙戦�佹暟鎹� + /// </summary> + /// <param name="sender"></param> + /// <param name="data"></param> + public bool SendData(byte[] data) + { + if (ComDevice.IsOpen) + { + try + { + ComDevice.Write(data, 0, data.Length);//鍙戦�佹暟鎹� + return true; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + finally + { + //cmdHSetZero.Enabled = true; + } + } + else + { + MessageBox.Show("涓插彛鏈墦寮�", "閿欒", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + return false; + } + + private void timer3_Tick(object sender, EventArgs e) + { + if (!ComDevice.IsOpen) + { + return; + } + byte[] sendData = strToHexByte(txtHSend.Text); + SendData(sendData); + + } + + /// <summary> + /// 鎺ユ敹鏁版嵁 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void Com_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + //if (!ComDevice.IsOpen) + //{ + // return; + //} + Thread.Sleep(100); + byte[] ReDatas = new byte[ComDevice.BytesToRead]; + ComDevice.Read(ReDatas, 0, ReDatas.Length);//璇诲彇鏁版嵁 + this.AddData(ReDatas);//杈撳嚭鏁版嵁 + } + + + ///// <summary> + ///// 娣诲姞鏁版嵁 + ///// </summary> + ///// <param name="data">瀛楄妭鏁扮粍</param> + //public void AddData(byte[] data) + //{ + // StringBuilder sb = new StringBuilder(); + // for (int i = 0; i < data.Length; i++) + // { + // sb.AppendFormat("{0:x2}" + " ", data[i]); + // } + // string str = sb.ToString().ToUpper() ; + // string[] strArr = str.Split(' '); + // string newStr = string.Empty; + // try + // { + // if (strArr[4] != "00") + // { + // char[] bw = strArr[4].ToCharArray(); + // if(bw[0]=='0') + // { + // newStr = bw[1].ToString(); + // } + // else + // { + // newStr = strArr[4]; + // } + + // } + // if (string.IsNullOrEmpty(newStr)) + // { + // char[] bw = strArr[5].ToCharArray(); + // if (bw[0] == '0') + // { + // newStr = bw[1].ToString(); + // } + // else + // { + // newStr = strArr[5]; + // } + // } + // else + // { + // newStr += strArr[5]; + // } + // if (strArr[6] != "00" && newStr=="00") + // { + // //newStr = $"0.{strArr[6]}"; + // newStr = "0." + strArr[6]; + // } + // if(strArr[6]!="00" && newStr != "00") + // { + // //newStr += $".{strArr[6]}"; + // newStr = newStr + strArr[6]; + + // } + // } + // catch + // { + // newStr = "-1"; + // } + // //灏嗗綋鍓嶆暟 鍘樼背 杞寲涓� 绫� + // double NewQty = DBUtility.ClsPub.isDoule(newStr) / 100.0000; + // if (NewQty <= 0) + // { + // newStr = "0"; + // } + // else + // { + // newStr = DBUtility.ClsPub.isDoule(NewQty, 2); + // } + // // + // lblHNowQty.Text = newStr; //褰撳墠绫虫暟 鏍囩 + // txtHDQQty.Text = newStr; //褰撳墠鏁伴噺 鏂囨湰 + // txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 2); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + // lblHRelQty.Text = txtHSJQty.Text; + //} + + + /// <summary> + /// 娣诲姞鏁版嵁 + /// </summary> + /// <param name="data">瀛楄妭鏁扮粍</param> + public void AddData(byte[] data) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < data.Length; i++) + { + sb.AppendFormat("{0:x2}" + " ", data[i]); + } + var str = sb.ToString().ToUpper().Trim(); + string[] strArr = str.Split(' '); + string newStr = string.Empty; + try + { + if (strArr[4] != "00") + { + char[] bw = strArr[4].ToCharArray(); + if(bw[0]=='0') + { + newStr = bw[1].ToString(); + } + else + { + newStr = strArr[4]; + } + + } + if (string.IsNullOrEmpty(newStr)) + { + char[] bw = strArr[5].ToCharArray(); + if (bw[0] == '0') + { + newStr = bw[1].ToString(); + } + else + { + newStr = strArr[5]; + } + } + else + { + newStr += strArr[5]; + } + if (strArr[6] != "00"&&newStr=="00") + { + //newStr = $"0.{strArr[6]}"; + newStr = "0." + strArr[6]; + } + if(strArr[6]!="00"&&newStr!="00") + { + //newStr += $".{strArr[6]}"; + newStr = newStr + "." + strArr[6]; + } + } + catch + { + newStr = "-1"; + } + + + //灏嗗綋鍓嶆暟 鍘樼背 杞寲涓� 绫� + double NewQty = DBUtility.ClsPub.isDoule(newStr) ; + if (NewQty <= 0) + { + newStr = "0"; + } + else + { + newStr = DBUtility.ClsPub.isDoule(NewQty, 1); + } + // + lblHNowQty.Text = newStr; //褰撳墠绫虫暟 鏍囩 + txtHDQQty.Text = newStr; //褰撳墠鏁伴噺 鏂囨湰 + if (DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text) > 0) + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + else + { + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text), 1); //瀹為檯绫虫暟= 褰撳墠绫虫暟-寮�濮嬬背鏁� + lblHRelQty.Text = txtHSJQty.Text; + } + } + + //鍒犻櫎閫変腑鐨勮鏁� + private void btnFQSH_Click(object sender, EventArgs e) + { + DelRow(); + } + + public void DelRow() + { + //WEBS + //if (!oWeb.getSecurity_Log(ModRightNameEdit, DBUtility.ClsPub.CurUserName, ref DBUtility.ClsPub.sExeReturnInfo)) + //{ + // MessageBox.Show("鎮ㄦ病鏈夊垹闄ゆ潈闄愶紒"); + // return; + //} + DataSet DS; + DataSet DS2; + bool sBool = true; + Int64 lngBillKey = 0; + if (grdMain.CurrentRow == null) + return; + if (MessageBox.Show("纭畾瑕佸垹闄ゆ墍閫夎锛�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) + { + for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++) + { + lngBillKey = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HItemID")].Value); + if (lngBillKey == 0) + return; + try + { + oWeb.getRunProc("Delete from Gy_BarCodeBill where HItemID=" + lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo); + oWeb.getRunProc("insert into System_log values(GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.CurUserName + "','鍒犻櫎鏉$爜锛�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉″舰鐮�")].Value) + "' ,'WMS绯荤粺','','鍒犻櫎')", ref DBUtility.ClsPub.sExeReturnInfo); + + } + catch (Exception e) + { + throw (e); + } + } + } + MessageBox.Show("鍒犻櫎鎴愬姛锛�", "鎻愮ず"); + DisplayMain(); + } + + private void btnFQBD_Click(object sender, EventArgs e) + { + //鏍规嵁鐣岄潰閫夋嫨鎵撳嵃妯℃澘锛屾墦鍗版潯褰㈢爜 + Sub_SetReportList(cmbFQMB.Text); + Report.PrintPreview(false); + Thread.Sleep(500); + } + + private void cmdHSaveInfo_Click(object sender, EventArgs e) + { + ClsIni.WriteIni("COMINFO", "txtPortName", DBUtility.ClsPub.isStrNull(txtPortName.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "txtBaudRate", DBUtility.ClsPub.isStrNull(txtBaudRate.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "cmbParity", DBUtility.ClsPub.isStrNull(cmbParity.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "txtDataBits", DBUtility.ClsPub.isStrNull(txtDataBits.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "cmbStopBits", DBUtility.ClsPub.isStrNull(cmbStopBits.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "txtHSend0", DBUtility.ClsPub.isStrNull(txtHSend0.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "txtHSend", DBUtility.ClsPub.isStrNull(txtHSend.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "txtHSourceID", DBUtility.ClsPub.isStrNull(txtHSourceID.Text), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + ClsIni.WriteIni("COMINFO", "txtHSourceIDTag", DBUtility.ClsPub.isStrNull(txtHSourceID.Tag), DBUtility.ClsPub.AppPath + @"/HXERP.ini"); + } + + private void btnBLHB_Click(object sender, EventArgs e) + { + Gy_BadReasonList oGy_BadReasonList = new Gy_BadReasonList(); + oGy_BadReasonList.ShowDialog(); + if (oGy_BadReasonList.ISOK == 1) + { + txtHReasonList.Text = ""; + txtHReasonList.Text = oGy_BadReasonList.txtHBadReason.Text; + if (SaveBadReasonBill()) + { + MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜鎴愬姛锛�"); + + DisplayMain(); + } + else + { + MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo); + } + } + oGy_BadReasonList = null; + } + + private void cmdSaveAndNext_Click(object sender, EventArgs e) + { + if (SaveBill("Save")) + { + txtHKSQty.Text = txtHDQQty.Text;//缁х画瑁佸垏锛屽皢褰撳墠绫虫暟浣滀负寮�濮嬬背鏁帮紱 + } + } + + private void btnBLBD_Click(object sender, EventArgs e) + { + + } + + private void btnBLSH_Click(object sender, EventArgs e) + { + + } + + private void cmdHWaitList_Click(object sender, EventArgs e) + { + //璺冲嚭璇ヤ骇绾� 鏈鐞嗙殑鍗曟嵁 + Sc_WaitingForCutting_List oSc_WaitingForCutting_List = new Sc_WaitingForCutting_List(); + if (HSourceBillType == "鐢熶骇璁㈠崟") + { + oSc_WaitingForCutting_List.HBillType = "3710"; + } + else if (HSourceBillType == "鐢熶骇姹囨姤鍗�") + { + oSc_WaitingForCutting_List.HBillType = "3711"; + } + else if (HSourceBillType == "鏀舵枡閫氱煡鍗�") + { + oSc_WaitingForCutting_List.HBillType = "1203"; + } + else + { + MessageBox.Show("閿欒鐨勫崟鎹被鍨嬶紒"); + return; + } + + oSc_WaitingForCutting_List.ShowDialog(); + + } + + private bool SaveBadReasonBill() + { + try + { + if (txtHReasonList.Text.Trim() == "") + { + MessageBox.Show("娌℃湁閫夋嫨涓嶈壇鍘熷洜锛�"); + return false; + } + //灏嗛�夋嫨涓嶈壇鍘熷洜鍒嗚В骞朵繚瀛樺叆鏁版嵁搴� + WMSWeb.ClsQC_NoPassProdCheckBillMain oQC_NoPassProdCheckBillMain = new WMSWeb.ClsQC_NoPassProdCheckBillMain(); + oQC_NoPassProdCheckBillMain.HDate = DateTime.Today; + oQC_NoPassProdCheckBillMain.HSourceID = DBUtility.ClsPub.isLong(txtHSourceID.Tag); + oQC_NoPassProdCheckBillMain.HMaterID = DBUtility.ClsPub.isLong(txtHMaterNumber.Tag); + oQC_NoPassProdCheckBillMain.HProcID = DBUtility.ClsPub.isLong(0); + oQC_NoPassProdCheckBillMain.HWorkCenterID = DBUtility.ClsPub.isLong(0); + oQC_NoPassProdCheckBillMain.HICMOInterID = 0; + oQC_NoPassProdCheckBillMain.HICMOBillNo = ""; + oQC_NoPassProdCheckBillMain.HInStockQty = 0; + oQC_NoPassProdCheckBillMain.HCheckQty = 0; + oQC_NoPassProdCheckBillMain.HRightQty = 0; + oQC_NoPassProdCheckBillMain.HBadQty = DBUtility.ClsPub.isDoule(txtHDQQty.Text); + oQC_NoPassProdCheckBillMain.HPlanQty = 0; + oQC_NoPassProdCheckBillMain.HBadPNL = 0; + oQC_NoPassProdCheckBillMain.HPlanPNL = 0; + oQC_NoPassProdCheckBillMain.HFirstCheckEmp = 0; + oQC_NoPassProdCheckBillMain.HCheckerResult = txtHReasonList.Text; + oQC_NoPassProdCheckBillMain.HNote = "鍦ㄧ嚎妫�楠�"; + oQC_NoPassProdCheckBillMain.HProcExchInterID = HSourceInterID;//婧愬崟涓诲唴鐮� + oQC_NoPassProdCheckBillMain.HProcExchEntryID = HSourceEntryID;//婧愬崟瀛愬唴鐮� + oQC_NoPassProdCheckBillMain.HProcExchBillNo = HSourceBillTypeID;//婧愬崟绫诲瀷 + oQC_NoPassProdCheckBillMain.HMainSourceInterID = 0; + oQC_NoPassProdCheckBillMain.HGroupName = ""; + oQC_NoPassProdCheckBillMain.HOrderProcNo = ""; + oQC_NoPassProdCheckBillMain.HProcExchQty = 0; + oQC_NoPassProdCheckBillMain.HBarCode = HBarCode; + if (oWeb.set_SaveNoPassProdCheckBill_New(oQC_NoPassProdCheckBillMain, HSourceBillTypeID, txtHReasonList.Text.Trim(), ref DBUtility.ClsPub.sExeReturnInfo)) + { + txtHReasonList.Text = ""; + return true; + } + txtHReasonList.Text = ""; + return false; + } + catch(Exception e1) + { + MessageBox.Show(e1.Message); + return false; + } + } + + private void cmdHSourceID_Click(object sender, EventArgs e) + { + SCM.ClsIF_Source_View oSource = new SCM.ClsIF_Source_View(); + string sWhere = ""; + if (oSource.RefreshView(sWhere)) + { + this.txtHSourceID.Text = oSource.oModel.HName; + this.txtHSourceID.Tag = oSource.oModel.HItemID.ToString(); + } + else + { + this.txtHSourceID.Text = ""; + } + } + + private void cmdSaveAndDown_Click(object sender, EventArgs e) + { + Gy_BadReasonList oGy_BadReasonList = new Gy_BadReasonList(); + oGy_BadReasonList.ShowDialog(); + if (oGy_BadReasonList.ISOK == 1) + { + txtHReasonList.Text = ""; + txtHReasonList.Text = oGy_BadReasonList.txtHBadReason.Text; oGy_BadReasonList = null; if (SaveBill("SaveDown")) { txtHKSQty.Text = txtHDQQty.Text;//缁х画瑁佸垏锛屽皢褰撳墠绫虫暟浣滀负寮�濮嬬背鏁帮紱 - } - if (SaveBadReasonBill()) - { - MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜鎴愬姛锛�"); - DisplayMain(); - } - else - { - MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo); - } - } - - } - - private void cmdHGroupID_Click(object sender, EventArgs e) - { - SCM.ClsIF_Group_View oGroup= new SCM.ClsIF_Group_View(); - string sWhere = ""; - if (oGroup.RefreshView(sWhere)) - { - this.txtHGroupID.Text = oGroup.oModel.HName; - this.txtHGroupID.Tag = oGroup.oModel.HItemID.ToString(); - } - else - { - this.txtHGroupID.Text = ""; - } - } - - private void txtHSourceID_TextChanged(object sender, EventArgs e) - { - if (txtHSourceID.Text.Trim() == "") - { - txtHSourceID.Tag = ""; - } - } - - private void txtHGroupID_TextChanged(object sender, EventArgs e) - { - if (txtHGroupID.Text.Trim() == "") - { - txtHGroupID.Tag = ""; - } - } - - private void cmdHEmp_Click(object sender, EventArgs e) - { - SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View(); - string sWhere = ""; - if (oEmp.RefreshView(sWhere)) - { - this.txtHEmpID.Text = oEmp.oModel.HName; - this.txtHEmpID.Tag = oEmp.oModel.HItemID.ToString(); - } - else - { - this.txtHEmpID.Text = ""; - } - } - - private void cmdHEmp2_Click(object sender, EventArgs e) - { - SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View(); - string sWhere = ""; - if (oEmp.RefreshView(sWhere)) - { - this.txtHEmpID2.Text = oEmp.oModel.HName; - this.txtHEmpID2.Tag = oEmp.oModel.HItemID.ToString(); - } - else - { - this.txtHEmpID2.Text = ""; - } - } - - private void txtHEmpID_TextChanged(object sender, EventArgs e) - { - if (txtHEmpID.Text.Trim() == "") - { - txtHEmpID.Tag = ""; - } - } - - private void txtHEmpID2_TextChanged(object sender, EventArgs e) - { - if (txtHEmpID2.Text.Trim() == "") - { - txtHEmpID2.Tag = ""; - } - } - - private void cmdHEmp3_Click(object sender, EventArgs e) - { - SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View(); - string sWhere = ""; - if (oEmp.RefreshView(sWhere)) - { - this.txtHEmpID3.Text = oEmp.oModel.HName; - this.txtHEmpID3.Tag = oEmp.oModel.HItemID.ToString(); - } - else - { - this.txtHEmpID3.Text = ""; - } - } - - private void txtHEmpID3_TextChanged(object sender, EventArgs e) - { - if (txtHEmpID3.Text.Trim() == "") - { - txtHEmpID3.Tag = ""; - } - } - - private void cmdZero_Click(object sender, EventArgs e) - { - txtHKSQty.Text = "0"; - txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); - - } - - private void cmdSaveAndDown2_Click(object sender, EventArgs e) - { - if (SaveBill("Sample")) - { - txtHKSQty.Text = txtHDQQty.Text;//缁х画瑁佸垏锛屽皢褰撳墠绫虫暟浣滀负寮�濮嬬背鏁帮紱 - } - } - - } + } + if (SaveBadReasonBill()) + { + MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜鎴愬姛锛�"); + DisplayMain(); + } + else + { + MessageBox.Show("淇濆瓨涓嶈壇鍘熷洜澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo); + } + } + + } + + private void cmdHGroupID_Click(object sender, EventArgs e) + { + SCM.ClsIF_Group_View oGroup= new SCM.ClsIF_Group_View(); + string sWhere = ""; + if (oGroup.RefreshView(sWhere)) + { + this.txtHGroupID.Text = oGroup.oModel.HName; + this.txtHGroupID.Tag = oGroup.oModel.HItemID.ToString(); + } + else + { + this.txtHGroupID.Text = ""; + } + } + + private void txtHSourceID_TextChanged(object sender, EventArgs e) + { + if (txtHSourceID.Text.Trim() == "") + { + txtHSourceID.Tag = ""; + } + } + + private void txtHGroupID_TextChanged(object sender, EventArgs e) + { + if (txtHGroupID.Text.Trim() == "") + { + txtHGroupID.Tag = ""; + } + } + + private void cmdHEmp_Click(object sender, EventArgs e) + { + SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View(); + string sWhere = ""; + if (oEmp.RefreshView(sWhere)) + { + this.txtHEmpID.Text = oEmp.oModel.HName; + this.txtHEmpID.Tag = oEmp.oModel.HItemID.ToString(); + } + else + { + this.txtHEmpID.Text = ""; + } + } + + private void cmdHEmp2_Click(object sender, EventArgs e) + { + SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View(); + string sWhere = ""; + if (oEmp.RefreshView(sWhere)) + { + this.txtHEmpID2.Text = oEmp.oModel.HName; + this.txtHEmpID2.Tag = oEmp.oModel.HItemID.ToString(); + } + else + { + this.txtHEmpID2.Text = ""; + } + } + + private void txtHEmpID_TextChanged(object sender, EventArgs e) + { + if (txtHEmpID.Text.Trim() == "") + { + txtHEmpID.Tag = ""; + } + } + + private void txtHEmpID2_TextChanged(object sender, EventArgs e) + { + if (txtHEmpID2.Text.Trim() == "") + { + txtHEmpID2.Tag = ""; + } + } + + private void cmdHEmp3_Click(object sender, EventArgs e) + { + SCM.ClsIF_Employee_View oEmp = new SCM.ClsIF_Employee_View(); + string sWhere = ""; + if (oEmp.RefreshView(sWhere)) + { + this.txtHEmpID3.Text = oEmp.oModel.HName; + this.txtHEmpID3.Tag = oEmp.oModel.HItemID.ToString(); + } + else + { + this.txtHEmpID3.Text = ""; + } + } + + private void txtHEmpID3_TextChanged(object sender, EventArgs e) + { + if (txtHEmpID3.Text.Trim() == "") + { + txtHEmpID3.Tag = ""; + } + } + + private void cmdZero_Click(object sender, EventArgs e) + { + txtHKSQty.Text = "0"; + txtHSJQty.Text = DBUtility.ClsPub.isDoule(DBUtility.ClsPub.isDoule(txtHDQQty.Text) - DBUtility.ClsPub.isDoule(txtHKSQty.Text), 1); + + } + + private void cmdSaveAndDown2_Click(object sender, EventArgs e) + { + if (SaveBill("Sample")) + { + txtHKSQty.Text = txtHDQQty.Text;//缁х画瑁佸垏锛屽皢褰撳墠绫虫暟浣滀负寮�濮嬬背鏁帮紱 + } + } + + } } \ No newline at end of file -- Gitblit v1.9.1