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 UIN060310 : FrmBase
{
public UIN060310()
{
InitializeComponent();
}
///
/// 初始化
///
#region "Init"
#endregion
///
/// 操作方法 查询
///
private void DoQuery()
{
try
{
this.dataSet1.Tables[0].Clear();
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 prcd = this.ultraComboEditor4.Text.ToString();
DateTime t1 = DateTime.ParseExact(DelToDateFrom, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
DateTime t2 = DateTime.ParseExact(DelToDateTo, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
System.TimeSpan t3 = t2 - t1; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
double getDay = t3.TotalDays; //将这个天数转换成天数, 返回值是double类型的(其实不必转换,因为t3默认就是天数) 得到:
if (getDay>30)
{
MessageBox.Show("查询周期过长,是否继续查询?");
}
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();
if (this.ultraComboEditor1.Text.ToString() == "全部")
{
if (this.ultraComboEditor2.Text.ToString() == "切割时间")
{
paramArray.Add("UIN060310_SLAB_NO1.Select");
}
else if (this.ultraComboEditor2.Text.ToString() == "申报时间")
{
paramArray.Add("UIN060310_SLAB_NOsb.Select");
}
else
{
paramArray.Add("UIN060310_SLAB_NO12.Select");
}
}
else if (this.ultraComboEditor1.Text.ToString() == "已申报")
{
if (this.ultraComboEditor2.Text.ToString() == "切割时间")
{
paramArray.Add("UIN060310_SLAB_NO2.Select");
}
else if (this.ultraComboEditor2.Text.ToString() == "申报时间")
{
paramArray.Add("UIN060310_SLAB_NOsb1.Select");
}
else {
paramArray.Add("UIN060310_SLAB_NO22.Select");
}
}
else {
if (this.ultraComboEditor2.Text.ToString() == "切割时间")
{
paramArray.Add("UIN060310_SLAB_NO3.Select");
}
else if (this.ultraComboEditor2.Text.ToString() == "申报时间")
{
paramArray.Add("UIN060310_SLAB_NOsb2.Select");
}
else {
paramArray.Add("UIN060310_SLAB_NO32.Select");
}
}
paramArray.Add(DelToDateFrom+"000000");
paramArray.Add(DelToDateTo+"999999");
paramArray.Add(coilNO);
if (prcd == "全部") prcd = "";
paramArray.Add(prcd);
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());
this.Docount();
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
private void Docount()
{
int coilCount = 0;
double actWgtSum = 0;
double thrWgtSum = 0;
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows)
{
double actWgt = 0;
double thrWgt = 0;
bool ifhide = ugr.HiddenResolved;
if (ifhide == false)
{
try
{
Color color = Color.SandyBrown;
string status = ugr.Cells["REPORTFLAG"].Value.ToString().Trim();
if ("未申报".Equals(status))
{
color = Color.White;
}
else if ("已申报".Equals(status))
{
color = Color.FromArgb(255, 128, 128);
}
ugr.Appearance.BackColor = color;
string zl2 = Convert.ToString(Common.FixDBManager.CheckNullStr(ugr.Cells["THR_WGT"].Text.ToString()));
if (zl2 == "") zl2 = "0";
string zl3 = Convert.ToString(Common.FixDBManager.CheckNullStr(ugr.Cells["SLAB_WGT"].Text.ToString()));
if (zl3 == "") zl3 = "0";
thrWgt = double.Parse(zl2);
actWgt = double.Parse(zl3);
thrWgtSum += thrWgt;
actWgtSum += actWgt;
coilCount = coilCount + 1;
}
catch (Exception e)
{
}
}
}
this.textBox1.Text = coilCount.ToString();
this.textBox2.Text = (Math.Round(thrWgtSum,3)).ToString();
this.textBox3.Text = (Math.Round(actWgtSum,3)).ToString();
// this.ultraGrid1.DisplayLayout.Bands[0].Summaries.
}
private void DoSave()
{
try
{
string strQueryFlag = "Y";
this.ultraGrid1.UpdateData();
ArrayList list = new ArrayList();
string[] param = null;
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIJ.UIJ06.UIJ060010";
string regid = this.UserInfo.GetUserName();
string bc = this.UserInfo.GetUserOrderText();
string reporttime = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMM")));
DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
for (int i = 0; i < selectedRows.Length; i++)
{
param = new string[3];
string slab_no= Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["SLAB_NO"]));
param[0] = slab_no;//板坯号
param[1] = reporttime;//申报时间
param[2] = bc;//班次
list.Add(param);
}
if (MessageBox.Show("确定将所选定板坯申报至" + reporttime+ "?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
return;
ccp.MethodName = "reportslab";
ccp.ServerParams = new Object[] { regid, list };
this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (strQueryFlag == "Y")
{
this.DoQuery();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
private void DoCancel()
{
try
{
string strQueryFlag = "Y";
this.ultraGrid1.UpdateData();
ArrayList list = new ArrayList();
string[] param = null;
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIJ.UIJ06.UIJ060010";
string regid = this.UserInfo.GetUserID();
string reporttime = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMM")));
DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
for (int i = 0; i < selectedRows.Length; i++)
{
param = new string[1];
string slab_no = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["SLAB_NO"]));
param[0] = slab_no;//板坯号
list.Add(param);
}
if (MessageBox.Show("确定取消所选板坯申报?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
return;
ccp.MethodName = "cancelreportslab";
ccp.ServerParams = new Object[] { regid, list };
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 UIN060310_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 "cancel":
this.DoCancel();
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)
{
if (ugr.HiddenResolved == false)//只处理过滤之后的数据
{
ugr.Cells["CHK"].Value = this.checkBox1.Checked;
ugr.Update();
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
#endregion
private void UIN060310_Load_1(object sender, EventArgs e)
{
this.ultraComboEditor1.SelectedIndex = 0;
this.ultraComboEditor3.SelectedIndex = 0;
this.ultraComboEditor2.SelectedIndex = 0;
}
private void ultraComboEditor3_ValueChanged_1(object sender, EventArgs e)
{
try
{
this.ultraGrid1.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
if (ultraComboEditor3.Text == "在库")
ultraGrid1.DisplayLayout.Bands[0].ColumnFilters["SLAB_STAT"].FilterConditions.Add(Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Like, "在*");
else if (ultraComboEditor3.Text == "出库")
ultraGrid1.DisplayLayout.Bands[0].ColumnFilters["SLAB_STAT"].FilterConditions.Add(Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Like, "出*");
this.Docount();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void ultraGrid1_FilterRow(object sender, FilterRowEventArgs e)
{
this.Docount();
List rows = this.ultraGrid1.Rows.Where(p => p.IsFilteredOut == false).ToList();//选择过滤后数据的代码
}
private void ultraGrid1_AfterRowFilterChanged(object sender, AfterRowFilterChangedEventArgs e)
{
this.Docount();
}
}
}