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 UIM010080 : FrmBase
{
public UIM010080()
{
InitializeComponent();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Export":
this.Export();
break;
case "Save":
this.DoSave();
break;
}
}
///
/// 查询原料库库存数据
///
private void DoQuery()
{
try
{
this.dataSet1.Tables[0].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[] queryParams = new string[] { startTime, endTime, specStlGrd, coilWthMin, coilWthMax,
coilThkMin, coilThkMax, curLoadLoc, coilNo, ordNo, ordSeq, ordFl, devlmtDate, progCd};
List list = new List();
list.Add(queryParams);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010080";
ccp.MethodName = "queryYardList";
ccp.ServerParams = new object[] { list };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, 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;
}
this.textBox1.Text = coilCount.ToString();
this.textBox2.Text = (coilWgtSum / 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());
}
}
private void UIM010080_Load(object sender, EventArgs e)
{
this.ultraDateTimeEditor1.Value = "" ;
this.ultraDateTimeEditor2.Value = "";
this.ultraDateTimeEditor3.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.UIM010080";
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());
}
}
}
}