| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using PrintSolution.LabelPrinter;
- using INI;
- using Infragistics.Win.UltraWinGrid;
- using System.Reflection;
- namespace Core.LZMes.Client.UIM.UIM02
- {
- public partial class UIM020060 : FrmBase
- {
- private ZebraPrinter printer = new ZebraPrinter();
- private Hashtable pkgHt = new Hashtable();
- private int hasPackaged = 0;
- public UIM020060()
- {
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- this.DoQuery();
- break;
- case "Save":
- this.DoSave();
- break;
- case "Export":
- this.DoExport();
- break;
- case "Print":
- this.DoPrint();
- break;
- case "Exit":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询原料库库存数据
- /// </summary>
- private void DoQuery()
- {
- try
- {
- this.dataSet1.Tables[0].Clear();
- string ordNo = this.textBox1.Text.Trim();//
- string ordSeq = this.textBox2.Text.Trim();//
- string coilNo = this.textBox3.Text.Trim();//
- hasPackaged = int.Parse(this.ultraComboEditor2.Value.ToString());
- string diiver = this.textBox4.Text.Trim();
- string startTime = "";
- string endTime = "";
- if (this.ultraCheckEditor1.Checked)
- {
- startTime = "";
- startTime = "";
- }
- else
- {
- startTime = this.ultraDateTimeEditor3.Value != null ? ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") : "";//开始时间
- endTime = this.ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";//结束时间
- }
- string prog = this.ultraComboEditor3.Value.ToString();
-
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM02.UIM020060";
- ccp.MethodName = "queryPkgCoil";
- ccp.ServerParams = new object[] { ordNo, ordSeq, coilNo, hasPackaged, diiver, startTime, endTime, prog };
- ccp.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
- //打印标签后颜色区分 20130314
- DataRowCollection drs = dataSet1.Tables[0].Rows;
- string ord_pak, pak, ordfl;
- for (int i = 0; i < drs.Count; i++)
- {
- if (drs[i]["PRINT_TP"].ToString().Equals("Y"))
- {
- if (!drs[i]["ORG_ORD_NO"].ToString().Equals(drs[i]["ORD_NO"].ToString())
- &&!drs[i]["ORG_ORD_SEQ"].ToString().Equals(drs[i]["ORD_SEQ"].ToString()))
- ultraGrid1.Rows[i].Appearance.BackColor = Color.FromArgb(192, 255, 192);
- }
- //订单包装要求跟实际包装不一致变红色
- ord_pak = drs[i]["PAKMTH_TP"].ToString().Trim();
- pak = drs[i]["PACKAGE_LEVEL"].ToString().Trim();
- ordfl = drs[i]["ORD_FL"].ToString().Trim();
- if (ord_pak != pak && "订单材".Equals(ordfl)) {
- ultraGrid1.Rows[i].Appearance.BackColor = Color.SandyBrown;
- }
- }
- //打印标签后颜色区分 20130314
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- private void DoSave()
- {
- ultraGrid1.Update();
- if (this.ultraDateTimeEditor1.Value == null)
- {
- MessageBox.Show("请选择包装日期!");
- this.ultraDateTimeEditor1.Focus();
- return;
- }
- ArrayList list = new ArrayList();
- ArrayList coilLables = new ArrayList();
- Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
- for (int i = 0; i < rs.Count; i++)
- {
- if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant()))
- {
- string packageLevel = rs[i].Cells["PACKAGE_LEVEL"].Text;
- if (packageLevel.Equals(""))
- {
- MessageBox.Show("第" + (i + 1) + "行包装等级为空,请核对后再点击保存!");
- return;
- }
- string[] packageArray = new string[2];
- packageArray[0] = rs[i].Cells["OLD_SAMPL_NO"].Value.ToString();
- packageArray[1] = pkgHt[rs[i].Cells["PACKAGE_LEVEL"].Text].ToString();
- list.Add(packageArray);
-
- //ColdCoilLable coilLabel = new ColdCoilLable();
- //coilLabel.rollNo = rs[i].Cells["OLD_SAMPL_NO"].Value.ToString().Substring(0,9);
- //coilLabel.specification = rs[i].Cells["SPEC_ABBSYM"].Value.ToString();
- //coilLabel.steelGrade = rs[i].Cells["SPEC_STL_GRD"].Value.ToString();
- //coilLabel.dimension = rs[i].Cells["PRINT_SIZE"].Value.ToString();
- //coilLabel.coilNo = rs[i].Cells["OLD_SAMPL_NO"].Value.ToString();
- //coilLabel.weight = rs[i].Cells["ACT_WGT"].Value.ToString();
- //coilLabel.heatNo = rs[i].Cells["CHARGE_NO"].Value.ToString();
- //coilLabel.prodDate = rs[i].Cells["MILL_DTIME"].Value.ToString();
- //coilLabel.contractNo = rs[i].Cells["ORD_NO"].Value.ToString() + "-" + rs[i].Cells["ORD_SEQ"].Value.ToString();
- //coilLabel.licenseNo = string.Empty;
- //coilLabel.licenseMark = string.Empty;
- //coilLabel.checker = string.Empty;
- //coilLabel.barcode = coilLabel.coilNo;
- //coilLables.Add(coilLabel);
- }
- }
- string pkgReg = this.UserInfo.GetUserID();
- string pkgShift = this.UserInfo.GetUserOrder();
- string pkgGroup = this.UserInfo.GetUserGroup();
- string pkgDtime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
- if (list.Count > 0)
- {
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM02.UIM020060";
- ccp.MethodName = "savePkgCoil";
- ccp.ServerParams = new object[] { list, pkgShift, pkgGroup, pkgReg, pkgDtime, hasPackaged };
- this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- //if (hasPackaged == 0)
- //{
- //print
- //PrintLabel(coilLables);
- //PrintLabel(coilLables);
- //}
- this.DoQuery();
- }
- }
- private void DoExport()
- {
- try
- {
- if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
- {
- string fileName = this.saveFileDialog1.FileName;
- ultraGridExcelExporter1.Export(ultraGrid1, fileName);
- System.Diagnostics.Process.Start(fileName);
- }
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- private void DoPrint()
- {
- ultraGrid1.UpdateData();
- //**************************
- Hashtable param = new Hashtable();
- string line = string.Empty;
- ArrayList coilLables = new ArrayList();
- Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
- for (int i = 0; i < rs.Count; i++)
- {
- if (Convert.ToBoolean(rs[i].Cells["CHK"].Value))
- {
- ColdCoilLable coilLabel = new ColdCoilLable();
- //coilLabel.rollNo = textBox9.Text.Trim().Substring(0, 9);//批号
- //coilLabel.specification = textBox8.Text.Trim();//标准号
- //coilLabel.steelGrade = textBox5.Text.Trim();//牌号
- //coilLabel.dimension = textBox15.Text.Trim() + "*" + textBox14.Text.Trim();//厚度、宽度
- //coilLabel.heatNo = textBox13.Text.Trim();//炉号
- coilLabel.rollNo = string.Empty; //批号
- coilLabel.specification = string.Empty; //标准号
- coilLabel.steelGrade = string.Empty; //牌号
- coilLabel.dimension = string.Empty; //厚度、宽度
- coilLabel.heatNo = string.Empty;//炉号
- coilLabel.coilNo = textBox9.Text.Trim();//卷号
- coilLabel.weight = textBox10.Text.Trim();//重量
- string millTime = textBox12.Text.Trim();//生产时间
- if (millTime != null && millTime != "")
- {
- coilLabel.prodDate = millTime.Replace(" ", "");//生产日期
- }
- else
- {
- coilLabel.prodDate = string.Empty;
- }
- if (checkBoxORD.Checked)//合同号
- {
- coilLabel.contractNo = textBox11.Text.Trim() + "-" + textBox7.Text.Trim();//合同号,订单号
- }
- else
- {
- coilLabel.contractNo = string.Empty;
- }
- if (this.checkBox3.Checked)//许可证号
- {
- coilLabel.licenseNo = this.textBoxLicenseNo.Text.Trim();
- }
- else
- {
- coilLabel.licenseNo = string.Empty;
- }
- if (this.checkBox4.Checked)//许可证标识
- {
- coilLabel.licenseMark = textBoxlicenseMark.Text;//string.Empty;
- }
- else
- {
- coilLabel.licenseMark = string.Empty;
- }
- coilLabel.checker = string.Empty;
- coilLabel.barcode = coilLabel.coilNo;
- coilLables.Add(coilLabel);
- line = rs[i].Cells["LINE_TP"].Text.ToString();
- }
- }
- //print
- try
- {
- PrintLabel(coilLables);
- PrintLabel(coilLables);
- PrintLabel(coilLables);//一次打印三张 20151231 WL
- PrintLabel(coilLables);//一次打印4张 20160805 WL
- //20130314添加标签打印标识
- string coilNo1 = this.textBox9.Text.Trim();
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM02.UIM020060";
- ccp.MethodName = "updateColor";
- ccp.ServerParams = new object[] { coilNo1 };
- ccp.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
- //20140304
- param.Add("i1", line);
- param.Add("i2", coilNo1);
- param.Add("i3", this.UserInfo.GetUserID());
- param.Add("i4", "标签打印");
- param.Add("i5", "UIM020060");
- param.Add("i6", "打印后");
- param.Add("o7", "");
- 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;
- }
- DoQuery();
- }
- catch (Exception ex)
- {
- MessageBox.Show("连接打印机失败,请点击\"打印\"按钮重新打印!");
- }
- }
- private void PrintLabel(ArrayList list)
- {
- foreach (ColdCoilLable coilLabel in list)
- {
- printer.printLable(coilLabel);
- }
- }
- private void UIM020060_Load(object sender, EventArgs e)
- {
- try {
- string Current = Directory.GetCurrentDirectory();//获取当前根目录
- Ini ini = new Ini(Current + "/CoreFS.ini");
- // 读取ini
- string labPrinterAddr = ini.ReadValue("LABPRINTERADDR", "4");
- printer.Addr = labPrinterAddr;
- /*string labPrinterAddr = "10.10.76.140";
- printer.Addr = labPrinterAddr;*/
- //string version = ini.ReadValue("LABPRINTERADDR", "Version");
- string version = "4";
- printer.LableVersion = int.Parse(version);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIM.UIM02.UIM020060";
- ccp.MethodName = "queryPkgType";
- ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
- ArrayList list = (ArrayList)ccp.ReturnObject;
- if (list != null)
- {
- this.ultraGrid1.DisplayLayout.ValueLists.Add("List1");
- int listSize = list.Count;
- for (int i = 0; i < listSize; i++)
- {
- Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
- Hashtable ht = (Hashtable)list[i];
- string smCd = ht["SM_CD"].ToString();
- string cmCfnm = "";
- object obj = ht["SM_CFNM"];
- if (obj != null)
- {
- cmCfnm = ht["SM_CFNM"].ToString();
- }
- pkgHt.Add(cmCfnm, smCd);
- this.ultraGrid1.DisplayLayout.ValueLists["List1"].ValueListItems.Add(smCd, cmCfnm);
- }
- this.ultraGrid1.DisplayLayout.ValueLists["List1"].DisplayStyle = Infragistics.Win.ValueListDisplayStyle.DisplayText;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["PACKAGE_LEVEL"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["PACKAGE_LEVEL"].ValueList = this.ultraGrid1.DisplayLayout.ValueLists["List1"];
- this.ultraComboEditor2.SelectedIndex = 0;
- this.ultraComboEditor3.SelectedIndex = 0;
- }
- }
- 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 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 custspecstl = 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;
- 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;
- custspecstl = e.Cell.Row.Cells["DDC_STL_GRD"].Text;
- }
- SetControlValue(coilNo, weight, ordNo, ordSeq, ordThk, ordWth, heatNo, steelCode, standardNo, millTime,custspecstl);
- e.Cell.Value = !Convert.ToBoolean(e.Cell.Value);
- }
- }
- catch (Exception ej)
- { System.Diagnostics.Debug.WriteLine(ej.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 custspecstl)
- {
- 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;
- textBox6.Text = custspecstl;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- string directoryPath = "C:\\Temp\\ZBS\\";
- int indexFlag = 0;
- foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHK"].Text) )
- {
- indexFlag++;
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIB.UIB03.TestPrint";
- ccp.MethodName = "print";
- ccp.ServerParams = new object[] { "G00001"
- ,ugr.Cells["OLD_SAMPL_NO"].Text
- };
- CoreClientParam cx = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- byte[] byData = (byte[])cx.ReturnObject;
- System.DateTime dt = System.DateTime.Now;
- string TimeNow = string.Format("{0:yyyyMMddHHmmssffff}", dt);
- string sFile = directoryPath + "ABC" + ".xls";
- FileStream fs = new FileStream(sFile, FileMode.OpenOrCreate, FileAccess.Write);
- fs.Write(byData, 0, byData.Length);
- fs.Close();
- Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
- Microsoft.Office.Interop.Excel.Workbook workbook = app.Application.Workbooks.Add(sFile);
- Microsoft.Office.Interop.Excel._Worksheet ws = (Microsoft.Office.Interop.Excel._Worksheet)workbook.Worksheets[1];
- ws.PrintOut(1, 1, 1, false, Missing.Value, false, false, Missing.Value);//"HP LaserJet P1505"
- workbook.Saved = true;
- workbook.Close(Missing.Value, Missing.Value, Missing.Value);
- app.Quit();
- System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
- System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
- app = null;
- GC.Collect();
- }
- }
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
- 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.textBoxLicenseNo.Enabled = this.checkBox3.Checked;
- this.textBoxLicenseNo.Enabled = this.checkBox3.Checked;
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
- private void checkBox4_Click(object sender, EventArgs e)
- {
- try
- {
- this.textBoxlicenseMark.Enabled = this.checkBox4.Checked;
- this.textBoxlicenseMark.Enabled = this.checkBox4.Checked;
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
- private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
- {
- if (this.ultraCheckEditor1.Checked)
- {
- this.ultraDateTimeEditor2.Enabled = false;
- this.ultraDateTimeEditor3.Enabled = false;
- //this.ultraCheckAll.Checked = false;
- }
- if (!this.ultraCheckEditor1.Checked)
- {
- this.ultraDateTimeEditor2.Enabled = true;
- this.ultraDateTimeEditor3.Enabled = true;
- }
- }
-
-
-
-
-
- }
- }
|