| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- 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.UIL.UIL01
- {
- public partial class UIL010020 : FrmBase
- {
- private ZebraPrinter printer = new ZebraPrinter();
- public UIL010020()
- {
- 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;
- case "Save":
- this.DoSave();
- break;
- case "Exit":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询原料库库存数据
- /// </summary>
- private void DoQuery()
- {
- try
- {
- switch (CustomInfo)
- {
- case "1":
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["CHK_Y"].Hidden = true;
- break;
- case "2":
- break;
- case "3":
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["CHK_Y"].Hidden = true;
- break;
- }
- this.dataSet1.Tables[0].Clear();
- string startTime = this.ultraDateTimeEditor1.Value != null ? this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";//生产开始时间
- string endTime = this.ultraDateTimeEditor2.Value != null ? this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";//生产结束时间
- string coilWthMin = this.textBox4.Text;//宽度最小值
- string coilWthMax = this.textBox5.Text;//宽度最大值
- string coilThkMin = this.textBox6.Text;//厚度最小值
- string coilThkMax = this.textBox7.Text;//厚度最大值
- string coilNo = this.textBox9.Text;//钢卷号
- string ordNo = this.textBox11.Text;//合同号
- string ordSeq = this.textBox3.Text;//订单号
- ArrayList list = new ArrayList();
- list.Add(startTime);
- list.Add(endTime);
- list.Add(coilThkMin);
- list.Add(coilThkMax);
- list.Add(coilWthMin);
- list.Add(coilWthMax);
- list.Add(ordNo);
- list.Add(ordSeq);
- list.Add(coilNo);
- list.Add(CustomInfo);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIL.UIL01.UIL010020";
- ccp.MethodName = "queryCoilList";
- ccp.ServerParams = new object[] { list };
- ccp.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
-
- //打印标签后颜色区分 20131017
- //DataRowCollection drs = dataSet1.Tables[0].Rows; 存在漏洞不是每行都能选中!!!!!!
- Infragistics.Win.UltraWinGrid.RowsCollection drs = this.ultraGrid1.Rows;
- for (int i = 0; i < drs.Count; i++)
- {
- if (drs[i].Cells["PRINT_TP"].Value.ToString().Trim().Equals("Y".ToString()))
- {
- ultraGrid1.Rows[i].Appearance.BackColor = Color.FromArgb(192, 255, 192);
- }
- }
- //打印标签后颜色区分 20131017
-
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- private void DoSave() {
- try {
- string coilNo = string.Empty;
- string prog = string.Empty;
-
- switch (CustomInfo)
- {
- case "2":
- Hashtable paramHsmp = new Hashtable();
- this.ultraGrid1.UpdateData();
- string regID = this.UserInfo.GetUserID();
- if (regID == "")
- {
- System.Windows.Forms.MessageBox.Show("!");
- return;
- }
- Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
- if (rs.Count > 0)
- {
- for (int i = 0; i < rs.Count; i++)
- {
- if (rs[i].Cells["CHK_Y"].Text.Trim() == "FALSE")
- {
- continue;
- }
- //else if (rs[i].Cells["CUR_PROG_CD"].Text.Trim() != "")
- //{
- // continue;
- //}
- else
- {
- paramHsmp = new Hashtable();
- coilNo = rs[i].Cells["COIL_NO"].Text.Trim();
- if (rs[i].Cells["CUR_PROG_CD"].Text.Trim().Equals("综合判定待机")) {
- prog="DED";
- }
- else if (rs[i].Cells["CUR_PROG_CD"].Text.Trim().Equals("重卷指示待机"))
- {
- prog = "DBA";
- }
- paramHsmp.Add("i1", coilNo);
- paramHsmp.Add("i2", prog);
- paramHsmp.Add("i3", regID);
- paramHsmp.Add("o4", "");
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIB.COM.ComDBProcedure";
- ccp.MethodName = "doXmlProcedure";
- ccp.ServerParams = new Object[] { "UIL010020_01_CALL.CALL", paramHsmp };
- this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- //提示
- ArrayList all = ccp.ReturnObject as ArrayList;
- if (all[0].ToString() != "YY")//确认是否存在问题
- {
- MessageBox.Show(all[0].ToString(), "提示");
- return;
- }
- }
- }
- }
- this.DoQuery();
- break;
- }
-
- }
- catch (Exception Ey)
- {
- MessageBox.Show(Ey.ToString());
- }
-
- }
- 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()
- {
- try
- {
- ultraGrid1.UpdateData();
- //----20131018
- Hashtable param= new Hashtable();
- string line = string.Empty;
- string printid = this.UserInfo.GetUserID();
- string flag = string.Empty;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
- {
- if (Convert.ToBoolean(row.Cells["CHK"].Value))
- {
- //----20131018
- param = new Hashtable();
-
- ColdCoilLable coilLabel = new ColdCoilLable();
- coilLabel.rollNo = string.Empty;
- coilLabel.specification = row.Cells["SPEC_ABBSYM"].Value.ToString();
- coilLabel.steelGrade = string.Empty;
- //if(Convert.ToBoolean(row.Cells["CHK_SIZE"].Value)){
- //coilLabel.dimension = row.Cells["COIL_SIZE"].Value.ToString();
- //}else{
- //coilLabel.dimension = row.Cells["ORD_SIZE"].Value.ToString();
- //}
- coilLabel.dimension = string.Empty;
- coilLabel.coilNo = row.Cells["COIL_NO"].Value.ToString();
- coilLabel.weight = row.Cells["ACT_WGT"].Value.ToString();
- coilLabel.heatNo = row.Cells["HEAT_NO"].Value.ToString();
- coilLabel.prodDate = row.Cells["MILL_DTIME"].Value.ToString();
- coilLabel.contractNo = string.Empty;
- coilLabel.licenseNo = string.Empty;
- coilLabel.licenseMark = string.Empty;
- coilLabel.checker = string.Empty;
- coilLabel.barcode = coilLabel.coilNo;
- if (row.Cells["PRINT_TP"].Text=="Y")
- {
- if (MessageBox.Show( row.Cells["COIL_NO"].Value.ToString()+"已打印,需要再次打印?",
- "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- switch (CustomInfo)
- {
- case "1":
- if (Convert.ToBoolean(row.Cells["CHK_SIZE"].Value))
- {
- coilLabel.dimension = row.Cells["COIL_SIZE"].Value.ToString();
- }
- else
- {
- coilLabel.dimension = row.Cells["ORD_SIZE"].Value.ToString();
- }
- coilLabel.steelGrade = row.Cells["SPEC_STL_GRD"].Value.ToString();
- //coilLabel.contractNo = row.Cells["ORD_NO"].Value.ToString() + "-" + row.Cells["ORD_SEQ"].Value.ToString();
- // coilLabel.contractNo = string.Empty;
- line = "S";
- flag = "A";
- break;
- case "2":
- //printer.printLable(coilLabel);
- line = "L";
- flag = "B";
- break;
- case "3":
- //coilLabel.dimension = string.Empty;
- line = "C";
- flag = "D";
- break;
- }
- string coilno = row.Cells["COIL_NO"].Value.ToString();
- printer.printLable(coilLabel);
- UpdateColor(coilno,flag);
- //----20131018
- param.Add("i1", line);
- param.Add("i2", coilno);
- param.Add("i3", printid);
- param.Add("i4", "标签打印");
- param.Add("i5", "UIL010020");
- param.Add("i6", "打印后");
- param.Add("o7", "");
- PrintHistory(param);
-
- }
- }
- else if (row.Cells["PRINT_TP"].Text == "N")
- {
- switch (CustomInfo)
- {
- case "1":
- if (Convert.ToBoolean(row.Cells["CHK_SIZE"].Value))
- {
- coilLabel.dimension = row.Cells["COIL_SIZE"].Value.ToString();
- }
- else
- {
- coilLabel.dimension = row.Cells["ORD_SIZE"].Value.ToString();
- }
- coilLabel.steelGrade = row.Cells["SPEC_STL_GRD"].Value.ToString();
- //coilLabel.contractNo = row.Cells["ORD_NO"].Value.ToString() + "-" + row.Cells["ORD_SEQ"].Value.ToString();
- //coilLabel.contractNo = string.Empty;
- line = "S";
- flag = "A";
- break;
- case "2":
- //printer.printLable(coilLabel);
- line = "L";
- flag = "B";
- break;
- case "3":
- // coilLabel.dimension = string.Empty;
- line = "C";
- flag = "D";
- break;
- }
- string coilno = row.Cells["COIL_NO"].Value.ToString();
- printer.printLable(coilLabel);
- UpdateColor(coilno, flag);
- //----20131018
- param.Add("i1", line);
- param.Add("i2", coilno);
- param.Add("i3", printid);
- param.Add("i4", "标签打印");
- param.Add("i5", "UIL010020");
- param.Add("i6", "打印后");
- param.Add("o7", "");
- PrintHistory(param);
-
- }
- }
- }
- 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 UIL010020_Load(object sender, EventArgs e)
- {
- try
- {
- string Current = Directory.GetCurrentDirectory();//获取当前根目录
- Ini ini = new Ini(Current + "/CoreFS.ini");
- // 读取ini
- string labPrinterAddr = ini.ReadValue("LABPRINTERADDR", CustomInfo);
- printer.Addr = labPrinterAddr;
- string version = ini.ReadValue("LABPRINTERADDR", "Version");
- printer.LableVersion = int.Parse(version);
- //MessageBox.Show(labPrinterAddr);
- }
- catch (Exception ej) {
- System.Diagnostics.Debug.WriteLine(ej.ToString());
- }
- }
- private void ultraButton1_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["COIL_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 ultraButton_print3_Click(object sender, EventArgs e)
- {
- printer.LableVersion = 3;
- DoPrint();
- }
-
-
- }
- }
|