| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using PrintSolution.LabelPrinter;
- using INI;
- using System.IO;
- using System.Collections;
- namespace Core.LZMes.Client.UIM.UIM02
- {
- public partial class UIM020103 : FrmBase
- {
- private ZebraPrinter printer = new ZebraPrinter();
- public UIM020103()
- {
- InitializeComponent();
- }
-
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- this.DoQuery();
- break;
- //case "Export":
- // this.DoExport();
- // break;
- case "Print":
- this.DoPrint();
- break;
- }
- }
- //
- public void DoQuery() {
- try {
- ArrayList al = new ArrayList();
- string startTime = this.ultraDateTimeEditor1.Value != null ? this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";//入库开始时间
- string entTime = this.ultraDateTimeEditor2.Value != null ? this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";//入库结束时间
- string driveNum = this.ultraTextEditor1.Text.Trim();
- string ord = this.ultraTextEditor2.Text.Trim();
- //钢卷号查询
- string coilNo = this.ultraTextEditor3_coilNo.Text.Trim();
- if (CustomInfo == "2")
- {
- if (Convert.ToBoolean(this.checkBox3.Checked))
- {
- if (coilNo == "")
- coilNo = "***";
- al.Add("UIM020103_01_CP_ALL_SUANXI.SELECT");
- al.Add(coilNo);
- }
- else
- {
- al.Add("UIM020103_01_CP_SUANXI.SELECT");
- al.Add(startTime);
- al.Add(entTime);
- al.Add(driveNum);
- al.Add(ord);
- }
- }
- else
- {
- if (Convert.ToBoolean(this.checkBox3.Checked))
- {
- if (coilNo == "")
- coilNo = "***";
- al.Add("UIM020103_01_CP_ALL.SELECT");
- al.Add(coilNo);
- }
- else
- {
- al.Add("UIM020103_01_CP.SELECT");
- al.Add(startTime);
- al.Add(entTime);
- al.Add(driveNum);
- al.Add(ord);
- }
- }
- this.dataSet1.Tables[0].Clear();
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIB.COM.ComDBQuery";
- ccp.MethodName = "doSimpleQuery";
- ccp.ServerParams = new object[] { al };
- ccp.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows)
- {
- string wth = ugr.Cells["COIL_WTH"].Text.Trim();
- string thk = ugr.Cells["COIL_THK"].Text.Trim();
- double b = double.Parse(ugr.Cells["C_ORD_THK_MAX"].Text.Trim());
- double c = double.Parse(ugr.Cells["C_ORD_THK_MIN"].Text.Trim());
- double d = double.Parse(ugr.Cells["C_ORD_WTH_MIN"].Text.Trim());
- double f = double.Parse(ugr.Cells["C_ORD_WTH_MAX"].Text.Trim());
- if (double.Parse(thk) > b || double.Parse(thk) < c || double.Parse(wth) < d || double.Parse(wth) > f)
- {
- ugr.Appearance.BackColor = Color.Yellow;
- }
- if (ugr.Cells["IS_CUT"].Text.Trim().Equals("N"))
- {
- ugr.Appearance.BackColor = Color.Orange;//LimeGreen
- }
- this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance = null;
- }
- ClearControlValue();
- }catch(Exception e){
- System.Diagnostics.Debug.WriteLine(e.ToString());
- }
- }
- public void DoPrint() {
- try
- {
- ultraGrid1.UpdateData();
- Hashtable param = new Hashtable();
- string printid = this.UserInfo.GetUserID();
- //若钢卷号查询条件不为空,则打印编辑区域信息,否则打印勾选的钢卷信息
- string coil_No = this.ultraTextEditor3_coilNo.Text.Trim();
- if (Convert.ToBoolean(this.checkBox3.Checked) && coil_No != null && coil_No != "")
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(row.Cells["CHK"].Value))
- {
- param = new Hashtable();
- ColdCoilLable coilLabel = new ColdCoilLable();
- coilLabel.rollNo = this.textBox9.Text.Substring(0, 9); //string.Empty;
- coilLabel.specification = this.textBox8.Text;
- coilLabel.steelGrade = this.textBox3.Text;//this.textBox3.Text为客户牌号
- coilLabel.dimension = this.textBox15.Text + "*" + this.textBox14.Text;
- coilLabel.coilNo = this.textBox9.Text;
- coilLabel.weight = this.textBox10.Text;
- coilLabel.heatNo = this.textBox13.Text;
- coilLabel.prodDate = this.textBox12.Text;
- coilLabel.contractNo = this.textBox11.Text;
- coilLabel.licenseNo = string.Empty;
- coilLabel.licenseMark = string.Empty;
- coilLabel.checker = this.textBox30.Text;
- coilLabel.barcode = coilLabel.coilNo;
- coilLabel.custName = this.textBox2.Text;
- coilLabel.prodName = this.textBox1.Text;
- if (this.textBox1_printYN.Text == "Y")
- {
- if (MessageBox.Show(this.textBox9.Text + "已打印,需要再次打印?",
- "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- string coilno = this.textBox9.Text;
- //打印两份20170117
- printer.printLable(coilLabel);
- printer.printLable(coilLabel); //20190304
- UpdateColor(coilno, "B");
- param.Add("i1", "L");
- param.Add("i2", coilno);
- param.Add("i3", printid);
- param.Add("i4", "标签打印");
- param.Add("i5", "UIM020102");
- param.Add("i6", "打印后");
- param.Add("o7", "");
- PrintHistory(param);
- }
- }
- else if (this.textBox1_printYN.Text == "N")
- {
- string coilno = this.textBox9.Text;
- printer.printLable(coilLabel);
- //20140507
- printer.printLable(coilLabel);
- UpdateColor(coilno, "B");
- param.Add("i1", "L");
- param.Add("i2", coilno);
- param.Add("i3", printid);
- param.Add("i4", "标签打印");
- param.Add("i5", "UIM020102");
- param.Add("i6", "打印后");
- param.Add("o7", "");
- PrintHistory(param);
- }
- }
- }
- }
- else
- {
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(row.Cells["CHK"].Value))
- {
- param = new Hashtable();
- ColdCoilLable coilLabel = new ColdCoilLable();
- coilLabel.rollNo = row.Cells["OLD_SAMPL_NO"].Value.ToString().Substring(0, 9); //string.Empty;
- coilLabel.specification = row.Cells["SPEC_ABBSYM"].Text;
- coilLabel.steelGrade = row.Cells["DDC_STL_GRD"].Text;//row.Cells["SPEC_STL_GRD"].Text;
- coilLabel.dimension = row.Cells["INSTR_COIL_THK"].Text + "*" + row.Cells["INSTR_COIL_WTH"].Text;//打印成品规格 20170109
- coilLabel.coilNo = row.Cells["OLD_SAMPL_NO"].Text;
- coilLabel.weight = row.Cells["ACT_WGT"].Text;
- coilLabel.heatNo = row.Cells["CHARGE_NO"].Text;
- coilLabel.prodDate = row.Cells["MILL_DTIME"].Text;
- coilLabel.contractNo = row.Cells["ORD_NO"].Text;
- coilLabel.licenseNo = string.Empty;
- coilLabel.licenseMark = string.Empty;
- //coilLabel.checker = string.Empty;
- coilLabel.checker = row.Cells["FAC_STL_GRD"].Text; //销售备注
- coilLabel.barcode = coilLabel.coilNo;
- coilLabel.custName = row.Cells["ORDCUST_CD"].Text;
- coilLabel.prodName = row.Cells["C_ORD_USE_TP"].Text;
- if (row.Cells["PRINT_TP"].Text == "Y")
- {
- if (MessageBox.Show(row.Cells["OLD_SAMPL_NO"].Value.ToString() + "已打印,需要再次打印?",
- "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- string coilno = row.Cells["OLD_SAMPL_NO"].Text;
- //打印两份 20170117
- printer.printLable(coilLabel);
- printer.printLable(coilLabel);
-
- UpdateColor(coilno, "B");
- param.Add("i1", "L");
- param.Add("i2", coilno);
- param.Add("i3", printid);
- param.Add("i4", "标签打印");
- param.Add("i5", "UIM020102");
- param.Add("i6", "打印后");
- param.Add("o7", "");
- PrintHistory(param);
- }
- }
- else if (row.Cells["PRINT_TP"].Text == "N")
- {
- string coilno = row.Cells["OLD_SAMPL_NO"].Text;
- printer.printLable(coilLabel);
- //20140507
- printer.printLable(coilLabel);
- UpdateColor(coilno, "B");
- param.Add("i1", "L");
- param.Add("i2", coilno);
- param.Add("i3", printid);
- param.Add("i4", "标签打印");
- param.Add("i5", "UIM020102");
- param.Add("i6", "打印后");
- param.Add("o7", "");
- PrintHistory(param);
- }
- }
- }
- }
- ClearControlValue();
- this.DoQuery();
- }
- catch (Exception EX)
- {
- MessageBox.Show("连接打印机失败,请点击\"打印\"按钮重新打印!");
- }
-
- }
- private void UpdateColor(string coilno,string flag) {
-
- CoreClientParam ccp1 = new CoreClientParam();
- ccp1.ServerName = "UIL.UIL01.UIL010020";
- ccp1.MethodName = "dateColor";
- ccp1.ServerParams = new object[] { coilno ,flag};
- ccp1.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal);
-
- }
- //标签打印记录增加
- private void PrintHistory(Hashtable param)
- {
- CoreClientParam ccp4 = new CoreClientParam();
- ccp4.ServerName = "UIB.COM.ComDBProcedure";
- ccp4.MethodName = "doXmlProcedure";
- ccp4.ServerParams = new Object[] { "UIL010020_02_CALL.CALL", param };
- this.ExecuteNonQuery(ccp4, CoreInvokeType.Internal);
- //提示
- ArrayList all = ccp4.ReturnObject as ArrayList;
- if (all[0].ToString() != "YY")//确认是否存在问题
- {
- MessageBox.Show(all[0].ToString(), "提示");
- return;
- }
- }
- private void UIM020103_Load(object sender, EventArgs e)
- {
- try
- {
- string Current = Directory.GetCurrentDirectory();//获取当前根目录
- Ini ini = new Ini(Current + "/CoreFS.ini");
- // ini.Writue("LABPRINTERADDR", "5", "10.10.76.211");
- // 读取ini
- // string labPrinterAddr = ini.ReadValue("LABPRINTERADDR", "5");
- string labPrinterAddr = "10.10.76.219";
- if (CustomInfo == "2")
- {
- labPrinterAddr = "10.10.76.220";
- }
- // labPrinterAddr = "172.16.50.200";//测试代码20161014
- printer.Addr = labPrinterAddr;
- string version = ini.ReadValue("LABPRINTERADDR", "Version");
-
- version = "5";//测试代码 20161014
- printer.LableVersion = int.Parse(version);
- //MessageBox.Show(labPrinterAddr);
- }
- catch (Exception ej)
- {
- System.Diagnostics.Debug.WriteLine(ej.ToString());
- }
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- try
- {
- if (e.Cell.Column.Key == "CHK")
- {
- //若钢卷号查询条件为空勾选时默认同发运号的钢卷都会勾选,否则只勾选当前钢卷并把钢卷信息填入编辑区域
- string coil_No = this.ultraTextEditor3_coilNo.Text.Trim();
- if (Convert.ToBoolean(this.checkBox3.Checked) && coil_No != null && coil_No != "")
- {
- string coilNo = string.Empty;
- string weight = string.Empty;
- string ordNo = string.Empty;
- string ordSeq = string.Empty;
- string ordThk = string.Empty;
- string ordWth = string.Empty;
- string heatNo = string.Empty;
- string steelCode = string.Empty;
- string standardNo = string.Empty;
- string millTime = string.Empty;
- string printTP = string.Empty;
- string prodname = string.Empty;
- string custname = string.Empty;
- string custspecstl = string.Empty;
- string beizhu = string.Empty;
- if (!Convert.ToBoolean(e.Cell.Value))
- {
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- ultraGrid1.Rows[i].Cells["CHK"].Value = false;
- }
- coilNo = e.Cell.Row.Cells["OLD_SAMPL_NO"].Text;
- weight = e.Cell.Row.Cells["ACT_WGT"].Text;
- ordNo = e.Cell.Row.Cells["ORD_NO"].Text;
- ordSeq = e.Cell.Row.Cells["ORD_SEQ"].Text;
- ordThk = e.Cell.Row.Cells["INSTR_COIL_THK"].Text;//打印成品规格 20170109
- ordWth = e.Cell.Row.Cells["INSTR_COIL_WTH"].Text;
- heatNo = e.Cell.Row.Cells["CHARGE_NO"].Text;
- steelCode = e.Cell.Row.Cells["SPEC_STL_GRD"].Text;
- standardNo = e.Cell.Row.Cells["SPEC_ABBSYM"].Text;
- millTime = e.Cell.Row.Cells["MILL_DTIME"].Text;
- printTP = e.Cell.Row.Cells["PRINT_TP"].Text;
- prodname = e.Cell.Row.Cells["C_ORD_USE_TP"].Text;
- custname = e.Cell.Row.Cells["ORDCUST_CD"].Text;
- custspecstl = e.Cell.Row.Cells["DDC_STL_GRD"].Text;
- beizhu = e.Cell.Row.Cells["FAC_STL_GRD"].Text;
- }
- SetControlValue(coilNo, weight, ordNo, ordSeq, ordThk, ordWth, heatNo, steelCode, standardNo, millTime, printTP, prodname, custname, custspecstl, beizhu);
- e.Cell.Value = !Convert.ToBoolean(e.Cell.Value);
- }
- else
- {
- e.Cell.Row.Update();
- if (e.Cell.Value.ToString().ToUpper() == "TRUE")
- {
- string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text;
- Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
- for (int i = 0; i < rs.Count; i++)
- {
- if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO)
- {
- rs[i].Cells["CHK"].Value = true;
- }
- else
- {
- rs[i].Cells["CHK"].Value = false;
- }
- }
- }
- else
- {
- string vDLIV_DIRNO = e.Cell.Row.Cells["DLIV_DIRNO"].Text;
- Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
- for (int i = 0; i < rs.Count; i++)
- {
- if (rs[i].Cells["DLIV_DIRNO"].Text == vDLIV_DIRNO)
- {
- rs[i].Cells["CHK"].Value = false;
- }
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
- private void SetControlValue(string coilNo, string weight, string ordNo, string ordSeq, string ordThk, string ordWth, string heatNo, string steelCode, string standardNo, string millTime, string printTP, string prodname, string custname, string custspecstl, string beizhu)
- {
- textBox9.Text = coilNo;
- textBox10.Text = weight;
- textBox12.Text = millTime;
- textBox11.Text = ordNo;
- textBox7.Text = ordSeq;
- textBox15.Text = ordThk;
- textBox14.Text = ordWth;
- textBox5.Text = steelCode;
- textBox8.Text = standardNo;
- textBox13.Text = heatNo;
- textBox1_printYN.Text = printTP;
- textBox1.Text = prodname;
- textBox2.Text = custname;
- textBox3.Text = custspecstl;
- textBox30.Text = beizhu;
- }
- private void ClearControlValue()
- {
- textBox9.Text = "";
- textBox10.Text = "";
- textBox12.Text = "";
- textBox11.Text = "";
- textBox7.Text = "";
- textBox15.Text = "";
- textBox14.Text = "";
- textBox5.Text = "";
- textBox8.Text = "";
- textBox13.Text = "";
- textBox1_printYN.Text = "";
- textBox1.Text = "";
- textBox2.Text = "";
- textBox3.Text = "";
- textBox30.Text = "";
- }
- private void checkBoxORD_Click(object sender, EventArgs e)
- {
- try
- {
- this.textBox11.Enabled = this.checkBoxORD.Checked;
- this.textBox7.Enabled = this.checkBoxORD.Checked;
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
- private void checkBox3_Click(object sender, EventArgs e)
- {
- try
- {
- this.ultraTextEditor3_coilNo.Enabled = this.checkBox3.Checked;
- ClearControlValue();
- this.DoQuery();
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
- }
- }
|