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;
}
}
///
///
///
///
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();
}
///
///
///
///
///
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();
}
}
}