| | |
| | | using System.IO; |
| | | using System.Management; |
| | | using System.Net.NetworkInformation; |
| | | using System.Printing; |
| | | |
| | | namespace WarM |
| | | { |
| | |
| | | #region çææé® |
| | | private void bc_Click(object sender, EventArgs e) |
| | | { |
| | | //å®¡æ ¸æé |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_BarCodeBill_automaticallyByPLC_ProduceByHand", 1, false, DBUtility.ClsPub.CurUserName)) |
| | | { |
| | | MessageBox.Show("çæå¤±è´¥ï¼æ æéï¼"); |
| | | return; |
| | | } |
| | | |
| | | //æ¸
餿å°ä»»å¡ |
| | | string msg = ""; |
| | | if (!clearPrinterTask(ref msg)) |
| | | { |
| | | MessageBox.Show(msg); |
| | | return; |
| | | } |
| | | |
| | | this.Sub_SaveBill(); |
| | | Display(); |
| | | |
| | | if (radioButton_IsPrint_Yes.Checked == true) |
| | | { |
| | | //设置æå°æ¨¡æ¿ï¼æå° |
| | | 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(); |
| | | } |
| | | //ä¿ååæ® |
| | |
| | | HWhID = ClsPub.isLong(grdSub.Rows[i].Cells[HWhID2Col].Value); |
| | | HSPID = ClsPub.isLong(grdSub.Rows[i].Cells[HSPID2Col].Value); |
| | | HRemark = ClsPub.isStrNull(grdSub.Rows[i].Cells[HRemark2Col].Value); |
| | | HRemark = "PLCèªå¨çæ"; |
| | | HMaterName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterName2Col].Value); |
| | | HMaterModel = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value); |
| | | HPinfan = ClsPub.isStrNull(grdSub.Rows[i].Cells[HPinfan2Col].Value); |
| | |
| | | string LIU = ""; |
| | | int LEN = 4; |
| | | 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 + "' 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 + "' and 夿³¨ = 'PLCèªå¨çæ' order by æ¹å· desc"; |
| | | ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList"); |
| | | if (ds != null) |
| | | { |
| | | long count = 0; |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | count = ClsPub.isLong(ds.Tables[0].Rows[0]["æ¹å·"].ToString().Replace(sYear + sPeriod + sDay, "")); |
| | | count = ClsPub.isLong(ds.Tables[0].Rows[0]["æ¹å·"].ToString().Replace(sYear + sPeriod + sDay+" ", "")); |
| | | } |
| | | LIU += count + 1; |
| | | while (LIU.Length < LEN) //å¦ææµæ°´å·å°äº6使°åé¢è¡¥0 |
| | |
| | | } |
| | | |
| | | //æ¼æ¥æ¹å· |
| | | HBatchNo = sYear + sPeriod + sDay + LIU; |
| | | HBatchNo = sYear + sPeriod + sDay+" " + LIU; |
| | | } |
| | | |
| | | |
| | |
| | | //æ¼æ¥æ¹å· |
| | | HBarCode_MaxNo = sYear + sPeriod + sDay + LIU; |
| | | |
| | | return HBarCode_MaxNo; |
| | | long HBarCode_MaxNo_long = long.Parse(HBarCode_MaxNo); |
| | | |
| | | while (true) |
| | | { |
| | | int HCount_BarCodeBillList = 0; |
| | | int HCount_SubBarCodeBill = 0; |
| | | string sql_confirm = "select * from h_v_IF_BarCodeBillList where æ¡ç ç¼å· = '" + (ClsPub.isStrNull(grdSub.Rows[0].Cells[HMaterModel2Col].Value) + HBarCode_MaxNo_long.ToString()) + "' and æ¡ç ç±»å = 'å¯ä¸æ¡ç '" + " and CONVERT(varchar(100),æ¡ç æ¥æ, 23) = '" + HDate + "'"; |
| | | ds = oCn.RunProcReturn(sql_confirm, "h_v_IF_BarCodeBillList"); |
| | | HCount_BarCodeBillList = ds.Tables[0].Rows.Count; |
| | | sql_confirm = "select * from Gy_BarCodeBill_SWELL_SubBarCodeBill Where HBarCode = '" + (ClsPub.isStrNull(grdSub.Rows[0].Cells[HMaterModel2Col].Value) + HBarCode_MaxNo_long.ToString()) + "' and HBarCodeType = 'å¯ä¸æ¡ç '" + " and CONVERT(varchar(100),HMakeDate, 23) = '" + HDate + "'"; |
| | | ds = oCn.RunProcReturn(sql_confirm, "Gy_BarCodeBill_SWELL_SubBarCodeBill"); |
| | | HCount_SubBarCodeBill = ds.Tables[0].Rows.Count; |
| | | if (HCount_BarCodeBillList + HCount_SubBarCodeBill > 0) |
| | | { |
| | | HBarCode_MaxNo_long += 1; |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return HBarCode_MaxNo_long.ToString(); |
| | | } |
| | | #endregion |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | //æ¸
餿宿尿ºä»»å¡ |
| | | private bool clearPrinterTask(ref string msg) |
| | | { |
| | | try |
| | | { |
| | | PrintServer localPrintServer = new LocalPrintServer(); |
| | | PrintQueue pq = localPrintServer.GetPrintQueue(comboBox_PrinterParams.Text.Replace("(é»è®¤)", "").ToLower()); |
| | | pq.Refresh(); |
| | | PrintJobInfoCollection allPrintJobs = pq.GetPrintJobInfoCollection(); |
| | | foreach (PrintSystemJobInfo printJob in allPrintJobs) |
| | | { |
| | | printJob.Cancel(); |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | msg = ex.Message; |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | //æ ¹æ®é讯信æ¯çææ¡ç å¹¶æå° |
| | | private void timer2_Tick(object sender, EventArgs e) |
| | | { |
| | | if (produceQty > 0) |
| | | { |
| | | //æ¸
餿å°ä»»å¡ |
| | | string msg = ""; |
| | | if (!clearPrinterTask(ref msg)) |
| | | { |
| | | MessageBox.Show(msg); |
| | | produceQty = 0; |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < produceQty; i++) |
| | | { |
| | | //çææ¡ç |
| | |
| | | //è·åéè¦æå°çæ°æ® |
| | | 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 != "") |
| | | if (radioButton_IsPrint_Yes.Checked == true) |
| | | { |
| | | Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(é»è®¤)", ""); |
| | | //设置æå°æ¨¡æ¿ï¼æå° |
| | | 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); |
| | | } |
| | | Report.Print(false); |
| | | |
| | | if (i == produceQty - 1) |
| | | { |
| | |
| | | { |
| | | sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value); |
| | | } |
| | | sMoney = Math.Round(sMoney, 10); // ä¿ç10ä½å°æ°è¿è¡åèäºå
¥ |
| | | sMoney = Math.Ceiling(sMoney); |
| | | grdMain.Rows[sRow].Cells[HBQtyCol].Value = sMoney; |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | timer1.Enabled = false; |
| | | //timer3.Enabled = false; |
| | | currentRepeatConnectTimes = 0; |
| | | MessageBox.Show("è¿æ¥å·²æå¼ï¼è¯·éæ°è¿æ¥ï¼!"); |
| | | } |
| | |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | #region 建ç«é讯åï¼ä¸æåæå¡å¨åéæ°æ®ï¼ç¨äºå¸®å©æå¡ç«¯ç¡®å®è¿æ¥ç¶æ |
| | | private void timer4_Tick(object sender, EventArgs e) |
| | | { |
| | | if (getTargetInternetStatus()&& socket!=null && socket.Connected) |
| | | { |
| | | try |
| | | { |
| | | socket.Send(Encoding.ASCII.GetBytes("1")); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |