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 Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Tool;
using Infragistics.Win.UltraWinGrid;
using Core.StlMes.Client.Mcp.Mch.Entity;
using com.steering.mes.mcp.entity;
using Core.Mes.Client.Comm.Server;
using Core.StlMes.Client.Mcp.Control;
namespace Core.StlMes.Client.Mcp.Mch.MchResult
{
public partial class FrmReason : FrmBase
{
UltraGridRow uge = null;
string gx = "";
public FrmReason()
{
InitializeComponent();
}
public FrmReason(OpeBase ob, UltraGridRow ugr,string GX)
{
InitializeComponent();
this.ob = ob;
uge = ugr;
gx = GX;
}
///
/// 查询废品原因
///
///
public void Query()
{
string startTim = "";
string endTim = "";
string heatid = "";
string judgeno = "";
if (chkTim.Checked)
{
if (DateTime.Parse(StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString()))
{
MessageUtil.ShowTips("选择时间区间错误,请重新选择!");
return;
}
else
{
startTim = this.StartTime.Value.ToString("yyyy-MM-dd 00:00:00");
endTim = this.EndTime.Value.ToString("yyyy-MM-dd 23:59:59");
}
}
if (!string.IsNullOrEmpty(planid.Text.Trim()))
{
heatid = planid.Text.ToString().Trim();
}
if(!string.IsNullOrEmpty(judgeNo.Text.Trim()))
{
judgeno = judgeNo.Text.ToString().Trim();
}
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmReason.doQuery", new object[] { startTim,endTim,heatid,judgeno }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
if(dt.Rows.Count<=0)
{
dataTable2.Clear();
}
}
private void FrmReason_Load(object sender, EventArgs e)
{
if (uge == null)
{
return;
}
else
{
init();
}
}
//界面初始化
private void init()
{
try
{
this.Cursor = Cursors.WaitCursor;
String heatplanno = uge.Cells["HEAT_PLAN_NO"].Value.ToString();
String lotno = uge.Cells["BATCH_NO"].Value.ToString();
String plinename = uge.Cells["PLINE_NAME"].Value.ToString();
}
catch (Exception ex)
{
MessageUtil.ShowTips("加载数据失败:" + ex.Message);
}
finally
{
this.Cursor = Cursors.Default;
}
}
/////
///// 删除废品原因
/////
/////
public void Delete()
{
if (ultraGrid1.ActiveRow != null)
{
UltraGridRow urg = ultraGrid1.ActiveRow;
if (urg != null)
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.Mch.FrmReason";
ccp.MethodName = "deletePerson";
ccp.ServerParams = new Object[] { urg.Cells["FAIL_REASON"].Value.ToString() };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("删除成功!"))
{
Query();
}
}
}
else
{
MessageUtil.ShowTips("请选择一条数据");
return;
}
}
}
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key.ToString())
{
case "Query":
Query();
break;
//case "Add":
// Add();
// break;
//case "Delete":
// Delete();
// break;
case "Close":
this.Close();
break;
}
}
private void ultraGrid4_AfterRowActivate(object sender, EventArgs e)
{
string heatno = "";
UltraGridRow urg = ultraGrid4.ActiveRow;
if(urg!=null)
{
heatno = urg.Cells["HEAT_PLAN_NO"].Value.ToString();
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmReason.queryfail", new object[] { heatno }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
foreach(UltraGridRow row in ultraGrid2.Rows)
{
if(row.Cells["FAIL_SORT"].Text.ToString()=="绝废")
{
row.Cells["FAIL_SORT"].Appearance.BackColor = Color.Red;
}
}
}
}
}
}