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 System.Collections;
using Infragistics.Win.UltraWinGrid;
namespace Core.LZMes.Client.UIN
{
public partial class UIN060120 : FrmBase
{
public UIN060120()
{
InitializeComponent();
}
///
/// 初始化
///
#region "Init"
public void init()
{
DataTable dt = new DataTable();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBQuery";
ccp.MethodName = "doSimpleQuery";
System.Collections.ArrayList paramArray = new ArrayList();
paramArray.Add("UIECOMM00_SELECT.CAL_MANA_NO");
ccp.ServerParams = new object[] { paramArray };
ccp.SourceDataTable = dt;
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
Core.LZMes.Client.UIE.UIE041.UIEBase.Init_ComboControl(this.ComboCalNO, ref dt, "CAL_NO");
this.ultraComboEditor2.SelectedIndex = 0;
}
#endregion
///
/// 操作方法 查询
///
private void DoQuery()
{
try
{
this.dataSet1.Tables[0].Clear();
string calNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ComboCalNO.Value));
string DelToDateFrom = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateFrom.DateTime.ToString("yyyyMMdd")));
string DelToDateTo = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateTo.DateTime.ToString("yyyyMMdd")));
string coilNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.textOrdNO.Text));
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBQuery";
ccp.MethodName = "doSimpleQuery";
ArrayList paramArray = new ArrayList();
paramArray.Add("UIN060120_COIL_NO.Select");
paramArray.Add(calNO);
paramArray.Add(DelToDateFrom);
paramArray.Add(DelToDateTo);
paramArray.Add(coilNO);
ccp.ServerParams = new object[] { paramArray };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
System.Diagnostics.Debug.WriteLine(this.dataSet1.Tables[0].ToString());
//a为原料重量 b为成品重量
double a1 = 0;
double b1 = 0;
double a2 = 0;
double b2 = 0;
double a3 = 0;
double b3 = 0;
double a4 = 0;
double b4 = 0;
double a5 = 0;
double b5 = 0;
double a6 = 0;
double b6 = 0;
double a7 = 0;
double b7 = 0;
double a8 = 0;
double b8 = 0;
for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
{
/*
* author: zmz
* 原料重量 成品重量根据订单厚度汇总
* cc 订单厚度
* aa 原料重量
* bb 成品重量
*/
double cc;
double aa;
double bb;
if (this.ultraGrid1.Rows[a].Cells["INSTR_COIL_THK"].Text == "") cc = 0;
else cc = double.Parse(this.ultraGrid1.Rows[a].Cells["INSTR_COIL_THK"].Value.ToString());
if (this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Text == "") aa = 0;
else aa = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
if (this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text == "") bb = 0;
else bb = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Value.ToString());
if (cc < 0.3)
{
a1 = a1 + aa;
b1 = b1 + bb;
}
else if (cc < 0.35)
{
a2 = a2 + aa;
b2 = b2 + bb;
}
else if (cc < 0.4)
{
a3 = a3 + aa;
b3 = b3 + bb;
}
else if (cc < 0.45)
{
a4 = a4 + aa;
b4 = b4 + bb;
}
else if (cc < 0.5)
{
a5 = a5 + aa;
b5 = b5 + bb;
}
else if (cc < 0.6)
{
a6 = a6 + aa;
b6 = b6 + bb;
}
else if (cc < 1.0)
{
a7 = a7 + aa;
b7 = b7 + bb;
}
else if (cc < 2.0)
{
a8 = a8 + aa;
b8 = b8 + bb;
}
}
this.textBox1.Text = (a1/1000).ToString();
this.textBox2.Text = (b1/1000).ToString();
this.textBox3.Text = (a2/1000).ToString();
this.textBox4.Text = (b2/1000).ToString();
this.textBox6.Text = (a3/1000).ToString();
this.textBox7.Text = (b3/1000).ToString();
this.textBox5.Text = (a4/1000).ToString();
this.textBox8.Text = (b4/1000).ToString();
this.textBox10.Text = (a5/1000).ToString();
this.textBox9.Text = (b5/1000).ToString();
this.textBox12.Text = (a6/1000).ToString();
this.textBox11.Text = (b6/1000).ToString();
this.textBox13.Text = (a7/1000).ToString();
this.textBox14.Text = (b7/1000).ToString();
this.textBox15.Text = (a8/1000).ToString();
this.textBox16.Text = (b8/1000).ToString();
for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
{
//double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() : "0");
string c = this.ultraGrid1.Rows[a].Cells["OLD_SAMPL_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 = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
double e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() : "0");
string f = this.ultraGrid1.Rows[d].Cells["OLD_SAMPL_NO"].Text.ToString();
if (f.Substring(0, 12) == c.Substring(0, 12))
{
b = b + e;
a = d;
}
else break;
}
double g = b / h * 100;
this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
}
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
private void DoQuery1()
{
try
{
this.dataSet1.Tables[0].Clear();
string calNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ComboCalNO.Value));
string DelToDateFrom = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateFrom.DateTime.ToString("yyyyMMdd")));
string DelToDateTo = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateTo.DateTime.ToString("yyyyMMdd")));
string coilNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.textOrdNO.Text));
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIB.COM.ComDBQuery";
ccp.MethodName = "doSimpleQuery";
ArrayList paramArray = new ArrayList();
paramArray.Add("UIN060120_COIL_NO.Select");
paramArray.Add(calNO);
paramArray.Add(DelToDateFrom);
paramArray.Add(DelToDateTo);
paramArray.Add(coilNO);
ccp.ServerParams = new object[] { paramArray };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
System.Diagnostics.Debug.WriteLine(this.dataSet1.Tables[0].ToString());
for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
{
//double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() : "0");
string c = this.ultraGrid1.Rows[a].Cells["OLD_SAMPL_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 = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
double e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() : "0");
string f = this.ultraGrid1.Rows[d].Cells["OLD_SAMPL_NO"].Text.ToString();
if (f.Substring(0, 12) == c.Substring(0, 12))
{
b = b + e;
a = d;
}
else break;
}
double g = b / h * 100;
this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
}
foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
{
if (ugr.Cells["CAL_GROUP"].Text == "")
{
string tem = ugr.Cells["MILL_DTIME"].Text.ToString();//20150302142567
//DateTime tem1 = DateTime.Parse(tem);
string temcoilno = ugr.Cells["OLD_SAMPL_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 ccp1 = new CoreClientParam();
ccp1.ServerName = "UIB.COM.ComDBSave";
ccp1.MethodName = "doXmlSave";
ArrayList paramArray1 = new ArrayList();
paramArray1.Add("UIN060120_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";
paramArray1.Add(millgroup);
millshift = "3";
paramArray1.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";
paramArray1.Add(millgroup);
paramArray1.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";
paramArray1.Add(millgroup);
millshift = "2";
paramArray1.Add(millshift);
}
paramArray1.Add(temcoilno);
ccp1.ServerParams = new object[] { paramArray1 };
this.ExecuteNonQuery(ccp1, 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("UIK020030_CUT.UPDATE");
// //paramArray.Add(cutEdgeYN);
// paramArray1.Add(temcoilno1);
// ccp3.ServerParams = new object[] { paramArray1 };
// this.ExecuteNonQuery(ccp3, CoreInvokeType.Internal);
//}
}
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 操作方法 保存班次组信息
///
private void DoSave()
{
try
{
string strQueryFlag = "Y";
this.ultraGrid1.UpdateData();
DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
for (int i = 0; i < selectedRows.Length; i++)
{
string regid = this.UserInfo.GetUserID();
string regshift = this.UserInfo.GetUserOrder();
string reggroup = this.ultraComboEditor2.Value.ToString();//this.UserInfo.GetUserGroup();
string coilno = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["OLD_SAMPL_NO"]));
string cutEdgeYN = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["CUT_EDGE_YN"]));
string isHead = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["ISHEAD"]));
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("UIN060120_shift.Update");
paramArray.Add(regid);
paramArray.Add(regshift);
paramArray.Add(reggroup);
paramArray.Add(cutEdgeYN);//isHead
paramArray.Add(isHead);//isHead
paramArray.Add(millDtime);
paramArray.Add(coilno);
ccp.ServerParams = new object[] { paramArray };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
}
if (strQueryFlag == "Y")
{
this.DoQuery();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.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());
}
}
///
/// 事件方法:
///
///
///
#region "EVENT 事件"
private void UIN060120_Load(object sender, EventArgs e)
{
init();
}
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;
}
}
private void ComboCalNO_ValueChanged(object sender, EventArgs e)
{
this.DoQuery();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
try
{
foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
{
ugr.Cells["CHK"].Value = this.checkBox1.Checked;
ugr.Update();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
#endregion
private void button1_Click(object sender, EventArgs e)
{
this.DoQuery1();
}
}
}