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;
namespace Core.LZMes.Client.UIM
{
public partial class UIM070010 : FrmBase
{
public UIM070010()
{
InitializeComponent();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Export":
this.Export();
break;
case "Exportd":
this.Exportd();
break;
case "Save":
this.DoSave();
break;
}
}
///
/// 查询原料库库存数据
///
private void DoQuery()
{
try
{
this.dataSet1.Tables[0].Clear();
this.dataSet1.Tables[1].Clear();
string startTime = this.ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";//入库开始时间
string endTime = this.ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";//入库结束时间
string specStlGrd = this.textBox3.Text.Trim();//牌号
string coilWthMin = this.textBox4.Text.Trim();//宽度最小值
string coilWthMax = this.textBox5.Text.Trim();//宽度最大值
string coilThkMin = this.textBox6.Text.Trim();//厚度最小值
string coilThkMax = this.textBox7.Text.Trim();//厚度最大值
string curLoadLoc = this.textBox8.Text.Trim();//垛位
string coilNo = this.textBox9.Text.Trim();//钢卷号
string ordNo = this.textBox11.Text.Trim();//订单号
string ordSeq = "";// this.textBox12.Text;//合同
string ordFl ="8"; //订单区分,默认为8
if (this.ultraComboEditor5.Text != "")
{
ordFl =this.ultraComboEditor5.Value.ToString();
}
string devlmtDate = this.ultraDateTimeEditor3.Value != null ? ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") : "";//交货期
string progCd = -1 == this.ultraComboEditor2.SelectedIndex ? "" : this.ultraComboEditor2.Value.ToString();//进程状态
string smptime = this.ultraDateTimeEditor4.Value != null ? ultraDateTimeEditor4.DateTime.ToString("yyyyMMdd") : "";//送样时间
string isspm = -1 == this.ultraComboEditor4.SelectedIndex ? "" : this.ultraComboEditor4.Value.ToString();//是否平整
string xsqy = this.textBox10.Text.Trim();//销售区域
string cpcoil = -1 == this.ultraComboEditor6.SelectedIndex ? "" : this.ultraComboEditor6.Value.ToString();//次品区分
string dlivtp = -1 == this.ultraComboEditor1.SelectedIndex ? "" : this.ultraComboEditor1.Value.ToString();//运输方式
string prodline = -1 == this.ultraComboEditor3.SelectedIndex ? "" : this.ultraComboEditor3.Value.ToString();//产线
string ordxz = -1 == this.ultraComboEditor7.SelectedIndex ? "" : this.ultraComboEditor7.Value.ToString();//合同类型性质
string rollmin = this.textBox12.Text.Trim();//轧辊单元最小
string rollmax = this.textBox13.Text.Trim();//单元最大
string[] queryParams = new string[] { startTime, endTime, specStlGrd, coilWthMin, coilWthMax,
coilThkMin, coilThkMax, curLoadLoc, coilNo, ordNo, devlmtDate, progCd,smptime, isspm,xsqy, cpcoil,dlivtp, prodline,ordxz,rollmin,rollmax };
List list = new List();
list.Add(queryParams);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM07.UIM070010";
ccp.MethodName = "queryHYardList";
ccp.ServerParams = new object[] { list };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
CoreClientParam ccpc = new CoreClientParam();
ccpc.ServerName = "UIM.UIM07.UIM070010";
ccpc.MethodName = "queryHYardListCount";
ccpc.ServerParams = new object[] { list };
ccpc.SourceDataTable = this.dataSet1.Tables[1];
this.ExecuteQueryToDataTable(ccpc, CoreInvokeType.Internal);
/*
Color color = Color.FromArgb(255, 255, 255);
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows)
{
string status = ugr.Cells["TOT_DEC_GRD"].Value.ToString().Trim();
string befstl = ugr.Cells["BEF_SPEC_STL_GRD"].Value.ToString().Trim();
string stl = ugr.Cells["SPEC_STL_GRD"].Value.ToString().Trim();
if ("合格".Equals(status))
{
color = Color.White;
}
else if ("不合格".Equals(status))
{
color = Color.FromArgb(255, 128, 128);
}
else
{
color = Color.SandyBrown;
}
if (befstl!=stl)
{
color = Color.Gold;
}
ugr.Appearance.BackColor = color;
}
*/
//统计钢卷数量,钢卷总重量
int coilCount = (int)dataSet1.Tables[0].Compute("count(OLD_SAMPL_NO)", "");
double coilWgtSum = 0;
foreach (DataRow dr in dataSet1.Tables[0].Rows)
{
double tmpWgt = 0;
try
{
tmpWgt = double.Parse(dr["ACT_WGT"].ToString());
}
catch (Exception e)
{
}
coilWgtSum += tmpWgt;
}
double coilWgtSum1 = 0; int count1 = 0;
double coilWgtSum2 = 0; int count2 = 0;
double coilWgtSum3 = 0; int count3 = 0;
double coilWgtSum4 = 0; int count4 = 0;
double coilWgtSum5 = 0; int count5 = 0;
double coilWgtSum6 = 0; int count6 = 0;
double coilWgtSum7 = 0; int count7 = 0;
foreach(Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows)
{
double actWgt1 = 0;
try
{
string status = ugr.Cells["CUR_PROG_CD"].Value.ToString().Trim();
if ("发货指示待机".Equals(status))
{
actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim());
coilWgtSum1 += actWgt1;
count1++;
}
else if ("综合判定待机".Equals(status))
{
actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim());
coilWgtSum2 += actWgt1;
count2++;
}
else if ("钢卷充当待机".Equals(status))
{
count3++;
actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim());
coilWgtSum3 += actWgt1;
}
else if ("运送待机".Equals(status))
{
actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim());
coilWgtSum4 += actWgt1;
count4++;
}
else if ("平整作业待机".Equals(status))
{
actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim());
coilWgtSum5 += actWgt1;
count5++;
}
else if ("移送待机".Equals(status))
{
actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim());
coilWgtSum6 += actWgt1;
count6++;
}
else if ("平整指示待机".Equals(status))
{
actWgt1 = double.Parse(ugr.Cells["ACT_WGT"].Value.ToString().Trim());
coilWgtSum7 += actWgt1;
count7++;
}
}
catch (Exception e)
{
}
}
//this.textBox1.Text = coilCount.ToString();
//this.textBox2.Text = (coilWgtSum / 1000).ToString();
//this.textBox14.Text = count1.ToString();
//this.textBox15.Text = (coilWgtSum1 / 1000).ToString();
//this.textBox16.Text = count2.ToString();
//this.textBox17.Text = (coilWgtSum2 / 1000).ToString();
//this.textBox18.Text = count3.ToString();
//this.textBox19.Text = (coilWgtSum3 / 1000).ToString();
//this.textBox20.Text = count4.ToString();
//this.textBox21.Text = (coilWgtSum4 / 1000).ToString();
//this.textBox22.Text = count5.ToString();
//this.textBox23.Text = (coilWgtSum5 / 1000).ToString();
//this.textBox24.Text = count6.ToString();
//this.textBox25.Text = (coilWgtSum6 / 1000).ToString();
//this.textBox26.Text = count7.ToString();
//this.textBox27.Text = (coilWgtSum7 / 1000).ToString();
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 导出EXCEL
///
private void Export()
{
try
{
if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
string fileName = this.saveFileDialog1.FileName;
this.ultraGridExcelExporter1.Export(ultraGrid1, fileName);
System.Diagnostics.Process.Start(fileName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
///
/// 导出EXCEL
///
private void Exportd()
{
try
{
if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
string fileName = this.saveFileDialog1.FileName;
this.ultraGridExcelExporter1.Export(ultraGrid2, fileName);
System.Diagnostics.Process.Start(fileName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void UIM070010_Load(object sender, EventArgs e)
{
this.ultraDateTimeEditor1.Value = "" ;
this.ultraDateTimeEditor2.Value = "";
this.ultraDateTimeEditor3.Value = "";
this.ultraDateTimeEditor4.Value = "";
}
private void DoSave()
{
Infragistics.Win.UltraWinGrid.RowsCollection rs = null;
ArrayList list = new ArrayList();
string[] param = null;
CoreClientParam ccp = new CoreClientParam();
rs = this.ultraGrid1.Rows;
for (int i = 0; i < rs.Count; i++)
{
if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant()))
{
param = new string[2];
param[0] = rs[i].Cells["LZBZ"].Text.ToString().Trim();
param[1] = rs[i].Cells["OLD_SAMPL_NO"].Value.ToString().Trim();
list.Add(param);
}
}
ccp.ServerName = "UIM.UIM070010";
ccp.MethodName = "addLzbz";
ccp.ServerParams = new Object[] { list };
this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
}
private void ultraGrid1_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e)
{
try
{
if (this.ultraGrid1.ActiveRow != null)
{
string COIL_NO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ultraGrid1.ActiveRow.Cells["H_COIL_NO"].Value));
UIM010081C frm = new UIM010081C();
frm.ob = this.ob;
frm.Condition = COIL_NO;
frm.ShowDialog();
//Core.LZMes.Client.UIB.UIB010301 frm = new Core.LZMes.Client.UIB.UIB010301();
//frm.ob = this.ob;
//frm.OrderNO = Common.FixDBManager.CheckNullStr(this.ugrd_RollPlan.ActiveRow.Cells["ORD_NO"].Value);
//frm.OrderSEQ = Common.FixDBManager.CheckNullStr(this.ugrd_RollPlan.ActiveRow.Cells["ORD_SEQ"].Value); ;
//frm.ShowDialog();
}
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
}
}