| | |
| | | using System.Drawing.Printing; |
| | | using System.IO; |
| | | using System.Management; |
| | | using System.Net.NetworkInformation; |
| | | |
| | | namespace WarM |
| | | { |
| | |
| | | //ç³»ç»åæ°ï¼çææ¡ç æ°éå¯å¦è¶
æºåæ°éæ§å¶ï¼N为ä¸å¯è¶
æºåæ°éï¼ |
| | | if (SourceQtyCtl == "N") |
| | | { |
| | | sWhere = " and HOrgID =" + HOrgID.ToString() + " and 任塿°é>0 and ç产线='" + comboBox_SourceNameParams.Text + "' "; |
| | | sWhere = " and HOrgID =" + HOrgID.ToString() + " and 任塿°é>0 and ç¶æ = 'å¼å·¥' and ç产线='" + comboBox_SourceNameParams.Text + "' "; |
| | | } |
| | | else |
| | | { |
| | | sWhere = " and HOrgID =" + HOrgID.ToString(); |
| | | sWhere = " and HOrgID =" + HOrgID.ToString() + " and ç¶æ = 'å¼å·¥' and ç产线='" + comboBox_SourceNameParams.Text + "' "; ; |
| | | } |
| | | |
| | | DAL.Cls_S_IFCLD_ICMOList oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList(); |
| | | DAL.Cls_S_IFCLD_ICMOList1 oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList1(); |
| | | if (oIFCLD_ICMOList.Refresh(sWhere)) //éæ©åå |
| | | { |
| | | FillSelectData(oIFCLD_ICMOList.oBillSelectColl); |
| | |
| | | //grdMain.Rows[i].Cells[HSourceNumberCol].Value = oTable.Rows[0]["ç产线代ç "].ToString(); |
| | | grdMain.Rows[i].Cells[HSourceNameCol].Value = oTable.Rows[0]["ç产线"].ToString(); |
| | | grdMain.Rows[i].Cells[HEndDateCol].Value = oTable.Rows[0]["计åå®å·¥æ¥æ"].ToString();//忥 ç产订å å¤±ææ¥æ |
| | | |
| | | grdMain.Rows[i].Cells[HAuxPropIDCol].Value = oTable.Rows[0]["HAuxPropID"].ToString(); |
| | | |
| | | if (cmbHBarCodeType.Text == "仪å¨å¤è´ä»¶æ¡ç 容å¨è§å") |
| | | { |
| | | grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["æªçææ¡ç æ°é"]); |
| | |
| | | { |
| | | this.Sub_SaveBill(); |
| | | Display(); |
| | | |
| | | //设置æå°æ¨¡æ¿ï¼æå° |
| | | grdList.Rows[0].Cells[0].Value = "*"; |
| | | Report = new GridppReport(); |
| | | Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf"); //here . |
| | | Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord); |
| | | Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable); |
| | | Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd); |
| | | if (comboBox_PrinterParams.Text != "") |
| | | { |
| | | Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(é»è®¤)", ""); |
| | | } |
| | | Report.Print(false); |
| | | |
| | | Display4(); |
| | | } |
| | |
| | | HBatchNo2 = getBatchNo(); |
| | | } |
| | | |
| | | HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value) + getHBarCode_MaxNo(); |
| | | |
| | | long HSourceID = 0; |
| | | string sql = "select * from Gy_Source where HName = '" + comboBox_SourceNameParams.Text + "' "; |
| | | DataSet ds = oCn.RunProcReturn(sql, "Gy_Source"); |
| | | if (ds != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | HSourceID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HItemID"].ToString()); |
| | | } |
| | | |
| | | oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" + |
| | | ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" + |
| | |
| | | ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " + |
| | | ",HProduceDate,HExpiryDate " + |
| | | ",HISKFPERIOD,HEXPUNIT,HEXPPERIOD " + |
| | | ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " + |
| | | ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HSourceID " + |
| | | ") values (" |
| | | + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString() |
| | | + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString() |
| | |
| | | + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag) + "," + HSeOrderSEQ.ToString() + "," + HSourceEntryID.ToString() |
| | | + ", " + (HProduceDate == "" ? "NULL" : "'" + HProduceDate + "'") + "," + (HExpiryDate == "" ? "NULL" : "'" + HExpiryDate + "'") |
| | | + ", " + DBUtility.ClsPub.BoolToString(HISKFPERIOD) + ",'" + HEXPUNIT + "'," + HEXPPERIOD.ToString() |
| | | + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "')"); |
| | | + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "'," + HSourceID + |
| | | ")"); |
| | | } |
| | | } |
| | | //å¢å æ¡ç è¶
è¿æªçæåè½æ§å¶ |
| | |
| | | string LIU = ""; |
| | | int LEN = 4; |
| | | DataSet ds; |
| | | string sql = "select * from h_v_IF_BarCodeBillList Where æºååå· ='" + grdMain.Rows[0].Cells[HSourceBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),æ¡ç æ¥æ, 23) = '" + HDate + "' order by æ¹å· desc"; |
| | | string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),æ¡ç æ¥æ, 23) = '" + HDate + "' order by æ¹å· desc"; |
| | | ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList"); |
| | | if (ds != null) |
| | | { |
| | |
| | | |
| | | return HBatchNo; |
| | | } |
| | | |
| | | //çæå½å¤©äº§åæ¡ç çæµæ°´å· |
| | | private string getHBarCode_MaxNo() |
| | | { |
| | | string HBarCode_MaxNo = ""; |
| | | |
| | | //æ¥æè·åæ¹å¼ |
| | | string sDate = dtpHDate.Value.ToShortDateString(); // |
| | | string sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2); |
| | | string sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString(); |
| | | sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2); |
| | | string sDay = "0" + ClsPub.isDate(sDate).Day.ToString(); |
| | | sDay = sDay.Substring(sDay.Length - 2, 2); |
| | | |
| | | string HDate = "20" + sYear + "-" + sPeriod + "-" + sDay; |
| | | |
| | | //è·åæµæ°´å·ï¼åä½ï¼è¯¥ç©æå½å¤©çæçæ¡ç æ° |
| | | string LIU = ""; |
| | | int LEN = 4; |
| | | |
| | | //è·åäº§åæ¡ç å¤ä»½è¡¨ä¸å½æ¥æ¬äº§åæ¡ç ç¼å·æå¤§çè®°å½ |
| | | long HMaxNo_Bak = 0; //è®°å½äº§åæ¡ç å¤ä»½è¡¨ä¸å½æ¥æ¬äº§åæ¡ç ç¼å·æå¤§çè®°å½çæ¡ç ç¼å·çæµæ°´å· |
| | | DataSet ds1; |
| | | string sql1 = "select * from Gy_BarCodeBill_SWELL_SubBarCodeBill Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),HBarCodeDate, 23) = '" + HDate + "' and HInterID <>0 order by HBarCode desc"; |
| | | ds1 = oCn.RunProcReturn(sql1, "Gy_BarCodeBill_SWELL_SubBarCodeBill"); |
| | | if (ds1 != null && ds1.Tables[0].Rows.Count>0) |
| | | { |
| | | string HBarCodeMaxNo = ds1.Tables[0].Rows[0]["HBarCode"].ToString(); |
| | | HBarCodeMaxNo = HBarCodeMaxNo.Substring(HBarCodeMaxNo.Length - LEN, LEN); |
| | | HMaxNo_Bak = ClsPub.isLong(HBarCodeMaxNo); |
| | | } |
| | | |
| | | ////è·åæ¡ç æ¡£æ¡ä¸å½æ¥æ¬äº§åæ¡ç ç¼å·æå¤§çè®°å½ |
| | | long HMaxNo = 0; //è®°å½æ¡ç æ¡£æ¡ä¸å½æ¥æ¬äº§åæ¡ç ç¼å·æå¤§çè®°å½çæ¡ç ç¼å·çæµæ°´å· |
| | | DataSet ds; |
| | | string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),æ¡ç æ¥æ, 23) = '" + HDate + "' and HInterID <> 0 order by æ¡ç ç¼å· desc"; |
| | | ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList"); |
| | | if (ds != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | string HBarCodeMaxNo = ds.Tables[0].Rows[0]["æ¡ç ç¼å·"].ToString(); |
| | | HBarCodeMaxNo = HBarCodeMaxNo.Substring(HBarCodeMaxNo.Length - LEN, LEN); |
| | | HMaxNo = ClsPub.isLong(HBarCodeMaxNo); |
| | | } |
| | | |
| | | |
| | | //è·å彿¥æ¬äº§å 卿¡ç æ¡£æ¡åäº§åæ¡ç å¤ä»½è¡¨ä¸ æå¤§çæµæ°´å· |
| | | long count = 0; |
| | | count = HMaxNo >= HMaxNo_Bak ? HMaxNo : HMaxNo_Bak; |
| | | |
| | | //ä¸ºæµæ°´å·åé¢è¡¥é¶ |
| | | LIU += count + 1; |
| | | while (LIU.Length < LEN) //å¦ææµæ°´å·å°äº6使°åé¢è¡¥0 |
| | | { |
| | | LIU = "0" + LIU; |
| | | } |
| | | |
| | | //æ¼æ¥æ¹å· |
| | | HBarCode_MaxNo = sYear + sPeriod + sDay + LIU; |
| | | |
| | | return HBarCode_MaxNo; |
| | | } |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region çå¬é讯 |
| | |
| | | { |
| | | try |
| | | { |
| | | if (socket != null && socket.Connected) |
| | | { |
| | | MessageBox.Show("已建ç«è¿æ¥ï¼ä¸å¯éå¤å»ºç«è¿æ¥ï¼"); |
| | | return; |
| | | } |
| | | |
| | | if (grdMain.Rows.Count == 0 || grdMain.Rows[0].Cells[HMaterIDCol].Value == null || grdMain.Rows[0].Cells[HMaterIDCol].Value.ToString() == "" || grdMain.Rows[0].Cells[HMaterIDCol].Value.ToString() == "0") |
| | | { |
| | | MessageBox.Show("è¯·éæ©æºåï¼"); |
| | |
| | | Thread thread = new Thread(ReceiveMess); |
| | | thread.Start(); |
| | | MessageBox.Show("è¿æ¥æåï¼"); |
| | | |
| | | timer3.Enabled = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | string RMess = Encoding.UTF8.GetString(buffer, 0, length); |
| | | produceQty = ClsPub.isLong(RMess); |
| | | if (produceQty == 0) |
| | | { |
| | | produceQty = 1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show("æ¥å£å¼å¸¸ï¼å·²å
³éè¿æ¥ï¼" + ex.Message); |
| | | socket.Close(); |
| | | //MessageBox.Show("æ¥å£å¼å¸¸ï¼å·²å
³éè¿æ¥ï¼" + ex.Message); |
| | | //socket.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | sDate = "20" + sYear + "-" + sPeriod + "-" + sDay; |
| | | |
| | | //è®¾ç½®å·¥åæ¡ç é项å¡è¡¨æ ¼æ°æ® |
| | | string sql = "select * from h_v_IF_BarCodeBillList Where æºååå· = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),æ¡ç æ¥æ, 23) = '" + sDate + "' order by æ¡ç ç¼å·"; |
| | | //string sql = "select * from h_v_IF_BarCodeBillList Where æºååå· = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),æ¡ç æ¥æ, 23) = '" + sDate + "' order by æ¡ç ç¼å·"; |
| | | string sql = "select * from h_v_IF_BarCodeBillList Where æºååå· = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and CONVERT(varchar(100),æ¡ç æ¥æ, 23) = '" + sDate + "' order by æ¡ç ç¼å·"; |
| | | DataSet DSet1 = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //çæé¦è¡æ é¢ |
| | | if (DSet1 == null) |
| | |
| | | if (socket.Connected) |
| | | { |
| | | socket.Close(); |
| | | MessageBox.Show("è¿æ¥å
³éæåï¼"); |
| | | } |
| | | else |
| | | { |
| | |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | timer3.Enabled = false; |
| | | } |
| | | } |
| | | #endregion |
| | |
| | | |
| | | |
| | | //设置产线 䏿å表 |
| | | DataSet DsSource = oCn.RunProcReturn("select * from Gy_Source where HUSEORGID =" + ClsPub.HOrgID, "Gy_Source"); |
| | | DataSet DsSource = oCn.RunProcReturn("select * from Gy_Source", "Gy_Source"); |
| | | comboBox_SourceNameParams.Items.Add(""); |
| | | if (DsSource != null) |
| | | { |
| | |
| | | { |
| | | return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList); |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | #region æçº¿éè¿ |
| | | private int maxRepeatConnectTimes = 5; |
| | | private int currentRepeatConnectTimes = 0; |
| | | |
| | | #region 宿¶å¨æ£æµè¿æ¥ç¶æãæçº¿éè¿ |
| | | private void timer3_Tick(object sender, EventArgs e) |
| | | { |
| | | if (currentRepeatConnectTimes < maxRepeatConnectTimes) |
| | | { |
| | | //夿客æ·ç«¯æ¯å¦å¯ä»¥è®¿é®æå¡å¨ï¼è¥ä¸å¯ä»¥è®¿é®ï¼å
³ésocketè¿æ¥ |
| | | if (!getTargetInternetStatus()) |
| | | { |
| | | if (socket != null && socket.Connected) |
| | | { |
| | | socket.Close(); |
| | | } |
| | | |
| | | currentRepeatConnectTimes += 1; |
| | | } |
| | | else if (getTargetInternetStatus() && !socket.Connected) |
| | | { |
| | | //è¥å®¢æ·ç«¯å¯ä»¥è®¿é®æå¡å¨ï¼socketéæ°è¿æ¥æå¡å¨ |
| | | try |
| | | { |
| | | socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); |
| | | IPAddress iPAddress = IPAddress.Parse(textBox_IPParams.Text); |
| | | IPEndPoint point = new IPEndPoint(iPAddress, Convert.ToInt32(textBox_PortParams.Text)); |
| | | socket.Connect(point); |
| | | |
| | | Thread thread = new Thread(ReceiveMess); |
| | | thread.Start(); |
| | | |
| | | currentRepeatConnectTimes = 0; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | currentRepeatConnectTimes += 1; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //timer3.Enabled = false; |
| | | currentRepeatConnectTimes = 0; |
| | | MessageBox.Show("è¿æ¥å·²æå¼ï¼è¯·éæ°è¿æ¥ï¼!"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region è·åç®æ 设å¤ç½ç»è¿æ¥ç¶æ |
| | | private bool getTargetInternetStatus() |
| | | { |
| | | try |
| | | { |
| | | string targetIp = textBox_IPParams.Text; // æ¿æ¢ä¸ºç®æ çµèçIPå°å |
| | | Ping pingSender = new Ping(); |
| | | PingOptions options = new PingOptions(); |
| | | // 使ç¨64åèçæ°æ®å
ï¼âä½ å¯ä»¥æ ¹æ®éè¦è°æ´è¿ä¸ªå¼ |
| | | string data = "Hello from Ping!"; |
| | | byte[] buffer = Encoding.ASCII.GetBytes(data); |
| | | int timeout = 1200; // è¶
æ¶æ¶é´ï¼âåä½ä¸ºæ¯«ç§ |
| | | PingReply reply = pingSender.Send(targetIp, timeout, buffer, options); |
| | | |
| | | if (reply.Status == IPStatus.Success) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | } |