| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- 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 System.Collections;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.LZMes.Client.UIK
- {
- public partial class UIK020080 : FrmBase
- {
- // public static UIK020080 s = null;
- public UIK020080()
- {
- InitializeComponent();
- // s = this;
- }
- private void UIK020080_Load(object sender, EventArgs e)
- {
- //CoreClientParam ccp = new CoreClientParam();
- //ccp.ServerName = "UIK.UIK02.UIK020040";
- //ccp.MethodName = "queryRollManaNo";
- //ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- //ArrayList list = (ArrayList)(ccp.ReturnObject);
- //if (list != null)
- //{
- // int listSize = list.Count;
- // Infragistics.Win.ValueListItem[] valueListItems = new Infragistics.Win.ValueListItem[listSize];
- // for (int i = 0; i < listSize; i++)
- // {
- // Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
- // string[] param = (string[])list[i];
- // item.DataValue = param[1];
- // item.DisplayText = param[1]; ;
- // valueListItems[i] = item;
- // }
- // this.ultraComboEditor1.Items.AddRange(valueListItems);
- // this.ultraComboEditor1.SelectedIndex = 0;
- //}
- this.ultraComboEditor2.SelectedIndex = 0;
- }
- 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 "Exit":
- this.Close();
- break;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- ///
-
- public void DoQuery()
- {
- //DateTime dt = DateTime.Parse("2015-03-02");
- //DateTime dt2 = DateTime.Now;
- //TimeSpan spanTime = (dt2 - dt);
- //string aa = spanTime.Days.ToString();
- // MessageBox.Show(aa);
- string rollManaNo = this.ultraComboEditor1.Text.Trim();
- string beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";
- string endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";
- string coilNo = textBox9.Text.Trim();
- if ("".Equals(rollManaNo) && ("".Equals(beginTime) || "".Equals(endTime)) && "".Equals(coilNo))
- {
- MessageBox.Show("请选择查询条件!" , "提示");
- return;
- }
- this.dataSet1.Tables[0].Clear();
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIB.COM.ComDBQuery";
- ccp.MethodName = "doSimpleQuery";
- ArrayList paramArray = new ArrayList();
- paramArray.Add("UIM010090_04.SELECT");
- // paramArray.Add(ordNo);
- // paramArray.Add(ordSeq);
- paramArray.Add(coilNo);
- ccp.ServerParams = new object[] { paramArray };
- ccp.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
- /*
- this.dataSet1.Tables[0].Clear();
- CoreClientParam ccp1 = new CoreClientParam();
- ccp1.ServerName = "UIK.UIK02.UIK020080";
- ccp1.MethodName = "queryColdCoilResult";
- ccp1.ServerParams = new object[] { rollManaNo, beginTime,endTime,coilNo };
- ccp1.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal);*/
-
- /*
- double sumh = 0;
- for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
- { double b;
- if (this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text == "")
- b = 0;
- else
- b= double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
- string c = this.ultraGrid1.Rows[a].Cells["C_COIL_NO"].Text.ToString();
- double h = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
- sumh=sumh+h;
- for (int d = a + 1; d <= this.ultraGrid1.Rows.Count - 1; d++)
- {
- double e;
- if (this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text == "")
- e = 0;
- else
- e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
- string f = this.ultraGrid1.Rows[d].Cells["C_COIL_NO"].Text.ToString();
- if (f.Substring(0, 11) == c.Substring(0, 11))
- {
- b = b + e;
- a = d;
- }
- else break;
- }
- double g = b / h * 100;
- this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
- }
- */
- }
- public void DoQuery1()
- {
- //DateTime dt = DateTime.Parse("2015-03-02");
- //DateTime dt2 = DateTime.Now;
- //TimeSpan spanTime = (dt2 - dt);
- //string aa = spanTime.Days.ToString();
- // MessageBox.Show(aa);
- string rollManaNo = this.ultraComboEditor1.Text.Trim();
- string beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.AddDays(-1).ToString("yyyyMMdd") : "";
- string endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";
- string coilNo = textBox9.Text.Trim();
- if ("".Equals(rollManaNo) && ("".Equals(beginTime) || "".Equals(endTime)) && "".Equals(coilNo))
- {
- MessageBox.Show("请选择查询条件!", "提示");
- return;
- }
- //this.dataSet1.Tables[1].Clear();
- //this.dataSet1.Tables[2].Clear();
- this.dataSet1.Tables[0].Clear();
- CoreClientParam ccp2 = new CoreClientParam();
- ccp2.ServerName = "UIK.UIK02.UIK020080";
- ccp2.MethodName = "queryColdCoilResult";
- ccp2.ServerParams = new object[] { rollManaNo, beginTime, endTime, coilNo };
- ccp2.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal);
- for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
- {
- double b;
- if (this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text == "")
- b = 0;
- else
- b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
- string c = this.ultraGrid1.Rows[a].Cells["C_COIL_NO"].Text.ToString();
- double h = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
- for (int d = a + 1; d <= this.ultraGrid1.Rows.Count - 1; d++)
- {
- double e;
- if (this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text == "")
- e = 0;
- else e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
- string f = this.ultraGrid1.Rows[d].Cells["C_COIL_NO"].Text.ToString();
- if (f.Substring(0, 11) == c.Substring(0, 11))
- {
- b = b + e;
- a = d;
- }
- else break;
- }
- double g = b / h * 100;
- this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
- }
- // DateTime dt = DateTime.Parse("2015-03-02");
- // DateTime dt2 = DateTime.Now;
- // TimeSpan spanTime = (dt2 - dt);
- // int subday = int.Parse(spanTime.Days.ToString());
- // int day1 = subday % 8;
- //string millgroup="1";
- foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
- {
- if (ugr.Cells["MILL_GROUP"].Text == "")
- {
- string tem = ugr.Cells["MILL_DTIME"].Text.ToString();//20150302142567
- //DateTime tem1 = DateTime.Parse(tem);
- string temcoilno = ugr.Cells["C_COIL_NO"].Text.ToString();
- DateTime tem1 = DateTime.ParseExact(tem, "yyyyMMddHHmmss", null);
- DateTime dt = DateTime.Parse("2015-03-02");
- DateTime dt2 = DateTime.Now;
- TimeSpan spanTime = (tem1 - dt);
- int subday = int.Parse(spanTime.Days.ToString());
- int day1 = subday % 8;
- string millgroup = "1";
- string millshift = "1";
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIB.COM.ComDBSave";
- ccp.MethodName = "doXmlSave";
- ArrayList paramArray = new ArrayList();
- paramArray.Add("UIK020080_group.UPDATE");
- if (tem1.Hour >= 0 && tem1.Hour < 8)//晚班
- {
- if (day1 == 0 || day1 == 1) millgroup = "3";
- else if (day1 == 2 || day1 == 3) millgroup = "2";
- else if (day1 == 4 || day1 == 5) millgroup = "1";
- else if (day1 == 6 || day1 == 7) millgroup = "4";
- paramArray.Add(millgroup);
- millshift = "3";
- paramArray.Add(millshift);
- }
- else if
- (tem1.Hour >= 8 && tem1.Hour < 16)//早班
- {
- if (day1 == 0 || day1 == 1) millgroup = "4";
- else if (day1 == 2 || day1 == 3) millgroup = "3";
- else if (day1 == 4 || day1 == 5) millgroup = "2";
- else if (day1 == 6 || day1 == 7) millgroup = "1";
- millshift = "1";
- paramArray.Add(millgroup);
- paramArray.Add(millshift);
- }
- else //中班
- {
- if (day1 == 0 || day1 == 1) millgroup = "1";
- else if (day1 == 2 || day1 == 3) millgroup = "4";
- else if (day1 == 4 || day1 == 5) millgroup = "3";
- else if (day1 == 6 || day1 == 7) millgroup = "2";
- paramArray.Add(millgroup);
- millshift = "2";
- paramArray.Add(millshift);
- }
- paramArray.Add(temcoilno);
- ccp.ServerParams = new object[] { paramArray };
- this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- if (double.Parse(ugr.Cells["SUBWTH"].Text.ToString()) > 10 && ugr.Cells["CUT_EDGE_YN"].Value.ToString()=="False")
- {
- string temcoilno1 = ugr.Cells["C_COIL_NO"].Text.ToString();
- CoreClientParam ccp3 = new CoreClientParam();
- ccp3.ServerName = "UIB.COM.ComDBSave";
- ccp3.MethodName = "doXmlSave";
- ArrayList paramArray1 = new ArrayList();
- paramArray1.Add("UIK020080_CUT.UPDATE");
- //paramArray.Add(cutEdgeYN);
- paramArray1.Add(temcoilno1);
- ccp3.ServerParams = new object[] { paramArray1 };
- this.ExecuteNonQuery(ccp3, CoreInvokeType.Internal);
- }
- }
- DoQuery();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DoSave()
- {
- string strQueryFlag = "Y";
- this.ultraGrid1.UpdateData();
- DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
- for (int i = 0; i < selectedRows.Length; i++)
- {
- try
- {
-
- string regid = this.UserInfo.GetUserID();
- string reggroup = this.ultraComboEditor2.Value.ToString();//this.UserInfo.GetUserGroup();
- string regshift = this.UserInfo.GetUserOrder();
- string coilno = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["C_COIL_NO"]));
- string cutEdgeYN = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["CUT_EDGE_YN"]));
- string millDtime = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["MILL_DTIME"]));
- if (millDtime.Length != 14)//长度
- {
- strQueryFlag = "N";
- MessageBox.Show("警告,钢卷" + coilno + "录入的日期长度" + millDtime + "错误,禁止保存", "提示");
- return;
- }
- if (Convert.ToInt16(millDtime.Substring(4, 2)) > 12) //月
- {
- strQueryFlag = "N";
- MessageBox.Show("警告,钢卷" + coilno + "录入的日期【月】" + millDtime + "错误,禁止保存", "提示");
- return;
- }
- if (Convert.ToInt16(millDtime.Substring(6, 2)) > 31) //日
- {
- strQueryFlag = "N";
- MessageBox.Show("警告,钢卷" + coilno + "录入的日期【日】" + millDtime + "错误,禁止保存", "提示");
- return;
- }
- if (Convert.ToInt16(millDtime.Substring(8, 2)) > 24) //小时
- {
- strQueryFlag = "N";
- MessageBox.Show("警告,钢卷" + coilno + "录入的日期【时】" + millDtime + "错误,禁止保存", "提示");
- return;
- }
- if (Convert.ToInt16(millDtime.Substring(10, 2)) > 59)//分
- {
- strQueryFlag = "N";
- MessageBox.Show("警告,钢卷" + coilno + "录入的日期【分】" + millDtime + "错误,禁止保存", "提示");
- return;
- }
- if (Convert.ToInt16(millDtime.Substring(12, 2)) > 59)//秒
- {
- strQueryFlag = "N";
- MessageBox.Show("警告,钢卷" + coilno + "录入的日期【秒】" + millDtime + "错误,禁止保存", "提示");
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "UIB.COM.ComDBSave";
- ccp.MethodName = "doXmlSave";
- ArrayList paramArray = new ArrayList();
- paramArray.Add("UIK020080_SHIFT.UPDATE");
- paramArray.Add(regid);
- paramArray.Add(regshift);
- paramArray.Add(reggroup);
- paramArray.Add(cutEdgeYN);
- paramArray.Add(millDtime);
- paramArray.Add(coilno);
- ccp.ServerParams = new object[] { paramArray };
- this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- }
- }
- if (strQueryFlag == "Y")
- {
- 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 ultraGrid1_ClickCell(object sender, Infragistics.Win.UltraWinGrid.ClickCellEventArgs e)
- {
- try
- {
- ultraGrid1.ActiveCell.SelectAll();
- }
- catch
- {
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.DoQuery1();
- }
- }
- }
|