using com.steering.mes.mcp.entity;
using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.Mcp.Control;
using CoreFS.CA06;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Core.Mes.Client.Comm.Format;
using Core.StlMes.Client.Mcp.Control.Entity;
namespace Core.StlMes.Client.Mcp.Control
{
public partial class FrmScrapHtt : FrmBase
{
private ArrayList list = null;
private string plineCode = "";
private string SLGx = "";
private string heatPlanNo = "";
private string resultNo = "";
public string reslNo = "";
public string Open = "";
private string save = "0";
private string Fenum = "";
public FrmScrapHtt(string heatNo,string slgx,string pline_Code,string ResultNo,string open,string fenum,OpeBase ob)
{
InitializeComponent();
//list = arr;
this.ob = ob;
plineCode = pline_Code;
SLGx = slgx;
heatPlanNo = heatNo;
resultNo = ResultNo;
Open = open;
Fenum = fenum;
}
///
/// 查询所有合格管序号
///
//private void QuerySeq(ArrayList list)
//{
// DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQuerySeq", new object[] { list }, ob);
// GridHelper.CopyDataToDatatable(ref ds, ref dataTable4, true);
//}
public string alamNum = "";
public string scrapNum = "";
public string testOfflineNum = "";
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case "Save":
Save();
break;
case "Close":
CloseFrm();
break;
}
}
public static int alarmTotalNum = 0;//可疑总支数
public static int scarpTotalNum = 0;//废品总支数
public static string dobiousName = "";//可疑原因
public static string failName = "";//废品原因
int offlineTotalNum = 0;//下线总支数
public static ArrayList dName = null;//怀疑
public static ArrayList fName = null;//废品
private void CloseFrm()
{
alamNum = alarmTotalNum.ToString();
scrapNum = scarpTotalNum.ToString();
testOfflineNum = offlineTotalNum.ToString();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
///
/// 保存可疑、剔除品
///
private void Save()
{
this.ultraGridDetailDes1.UpdateData();
this.ultraGridDetailDes2.UpdateData();
// this.ultraGridDetailDes3.UpdateData();
// string strInbound = "800707";//入库类型
//string strInMemo = "";
alarmTotalNum = 0;
scarpTotalNum = 0;
offlineTotalNum = 0;
IQueryable checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'");
IQueryable checkScrapRows = this.ultraGridDetailDes2.Rows.AsQueryable().Where(" CHK = 'True'");
// IQueryable checkOffineRow = this.ultraGridDetailDes3.Rows.AsQueryable().Where(" CHK = 'True'");
ArrayList alarmlist = new ArrayList();
ArrayList scraplist = new ArrayList();
//ArrayList offlinelist = new ArrayList();
foreach (UltraGridRow uRow in checkAlarmRows)
{
ArrayList list1 = new ArrayList();
if (uRow.Cells["DEF_FILL_NAME"].Text.ToString() == "")
{
MessageUtil.ShowTips("可疑支数原因不能为空,请选择!");
return;
}
if (uRow.Cells["DEF_FILL_NUM"].Value.ToString() == "" || uRow.Cells["DEF_FILL_NUM"].Value.ToString() == "0")
{
MessageUtil.ShowTips("可疑支数不能为空或者为零支,请输入!");
return;
}
if (!uRow.Cells["DEF_FILL_NUM"].Value.ToString().TryParseInt())
{
MessageUtil.ShowTips("可疑支数请输入整数!");
return;
} if (Convert.ToInt32(Fenum) < Convert.ToInt32(uRow.Cells["DEF_FILL_NUM"].Value.ToString()))
{
MessageUtil.ShowTips("可疑支数不能大于加工支数!");
return;
}
alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["DEF_FILL_NUM"].Value.ToString3());
//list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim());
//list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3());
//list1.Add(alarmTotalNum.ToString());
//alarmlist.Add(list1);
HttWasteResultEntity resultD = getRowData(uRow);
resultD.ResultNo = uRow.Cells["DEF_SERIAL_ITEM"].Value.ToString();
alarmlist.Add(JSONFormat.Format(resultD));
}
dName = alarmlist;
//int n = 0;
//foreach (UltraGridRow ugr in checkScrapRows)
//{
// //string alarmReason = ugr.Cells["REASON1"].Text.Trim();
// int num = 0;
// foreach (UltraGridRow ugr1 in checkAlarmRows)
// {
// if (ugr1.Cells["FAIL_TYPE_NAME"].Text.Trim().Equals(alarmReason))
// {
// num = num + int.Parse(ugr1.Cells["FAIL_NUM"].Value.ToString3());
// }
// }
// if (num < int.Parse(ugr.Cells["FAIL_NUM"].Value.ToString3()))
// {
// n = n + 1;
// }
//}
//if (n > 0)
//{
// MessageUtil.ShowTips("废品支数不能超出对应的报警原因下的支数!");
// return;
//}
foreach (UltraGridRow row in checkScrapRows)
{
ArrayList list2 = new ArrayList();
//if (row.Cells["REASON1"].Value.ToString2() == "")
//{
// MessageUtil.ShowTips("报警原因不能为空,请选择!");
// return;
//}
if (row.Cells["DEF_FILL_NAME"].Text.ToString() == "")
{
MessageUtil.ShowTips("废品原因不能为空,请选择!");
return;
}
if (row.Cells["DEF_FILL_NUM"].Value.ToString() == "" || row.Cells["DEF_FILL_NUM"].Value.ToString() == "0")
{
MessageUtil.ShowTips("废品支数不能为空或者为零支,请输入!");
return;
}
if (!row.Cells["DEF_FILL_NUM"].Value.ToString().TryParseInt())
{
MessageUtil.ShowTips("废品支数请输入整数!");
return;
}
if (Convert.ToInt32(Fenum) < Convert.ToInt32(row.Cells["DEF_FILL_NUM"].Value.ToString()))
{
MessageUtil.ShowTips("废品支数不能大于加工支数!");
return;
}
scarpTotalNum = scarpTotalNum + int.Parse(row.Cells["DEF_FILL_NUM"].Value.ToString3());
//list2.Add(row.Cells["FAIL_TYPE_NAME"].Text.Trim());
//list2.Add(row.Cells["FAIL_NUM"].Value.ToString3());
//list2.Add(scarpTotalNum.ToString());
////list2.Add(row.Cells["REASON1"].Text.Trim());
//scraplist.Add(list2);
HttWasteResultEntity resultD = getRowData(row);
resultD.ResultNo = row.Cells["DEF_SERIAL_ITEM"].Value.ToString();
scraplist.Add((JSONFormat.Format(resultD)));
}
fName = scraplist;
if(dName.Count!=0||fName.Count!=0)
{
MessageUtil.ShowTips("添加成功!");
save = "1";
alamNum = alarmTotalNum.ToString();
scrapNum = scarpTotalNum.ToString();
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
//CoreClientParam ccp = new CoreClientParam();
//ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmHttBugD";
//ccp.MethodName = "addPerson";
//ccp.ServerParams = new object[] { alarmlist, scraplist, SLGx, plineCode, heatPlanNo };
//ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
//if (ccp.ReturnCode != -1)
//{
// MessageUtil.ShowTips(ccp.ReturnInfo);
// if (ccp.ReturnInfo.Equals("保存成功!"))
// {
// save = "1";
// alamNum = alarmTotalNum.ToString();
// scrapNum = scarpTotalNum.ToString();
// //testOfflineNum = offlineTotalNum.ToString();
// //UltraGridRow urg = ultraGridDetailDes2.ActiveRow;
// //if(urg!=null)
// //{
// // reslNo = urg.Cells["RESULT_NO"].Value.ToString();
// //}
// this.DialogResult = System.Windows.Forms.DialogResult.OK;
// }
// else
// {
// MessageUtil.ShowTips(ccp.ReturnInfo);
// }
//}
}
public HttWasteResultEntity getRowData(UltraGridRow checkrow)
{
HttWasteResultEntity resultD = new HttWasteResultEntity();
resultD.DefFillName = checkrow.Cells["DEF_FILL_NAME"].Text.ToString().Trim();
resultD.DefFillNum = decimal.Parse(checkrow.Cells["DEF_FILL_NUM"].Value.ToString2().Trim());
return resultD;
}
///
/// 查询仓库信息
///
///
///
private DataTable getStoreNo(string plineCode)
{
DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
if (ds.Rows.Count > 0)
{
return ds;
}
else
{
return null;
}
}
private void FrmScrap_Load(object sender, EventArgs e)
{
// Init(plineCode);
doQuery();
if (Open == "0")
{
ultraGroupBox2.Hide();
}
//QuerySeq(list);
}
public void Init(string plineCode)
{
ValueList va1 = new ValueList();
ValueList va2 = new ValueList();
ValueList va3 = new ValueList();
ValueList va4 = new ValueList();
if (plineCode != null)
{
if (plineCode.Equals("C009") || plineCode.Equals("C017") || plineCode.Equals("C008"))
{
va1.ValueListItems.Add("");
va1.ValueListItems.Add("LOD");
va1.ValueListItems.Add("LID");
va1.ValueListItems.Add("TOD");
va1.ValueListItems.Add("TID");
va4.ValueListItems.Add("");
va4.ValueListItems.Add("LOD");
va4.ValueListItems.Add("LID");
va4.ValueListItems.Add("TOD");
va4.ValueListItems.Add("TID");
va2.ValueListItems.Add("");
va2.ValueListItems.Add("内折");
va2.ValueListItems.Add("内结疤");
va2.ValueListItems.Add("内划伤");
va2.ValueListItems.Add("拉凹");
va2.ValueListItems.Add("内棱");
va2.ValueListItems.Add("取样废");
va2.ValueListItems.Add("内壁伤");
va2.ValueListItems.Add("内鼓包");
va2.ValueListItems.Add("外折");
va2.ValueListItems.Add("外结疤");
va2.ValueListItems.Add("外划伤");
va2.ValueListItems.Add("裂纹");
va2.ValueListItems.Add("靑线");
va2.ValueListItems.Add("轧折");
va2.ValueListItems.Add("碰伤");
va2.ValueListItems.Add("孔洞");
va2.ValueListItems.Add("其他");
va3.ValueListItems.Add("");
va3.ValueListItems.Add("内折");
va3.ValueListItems.Add("内结疤");
va3.ValueListItems.Add("内划伤");
va3.ValueListItems.Add("拉凹");
va3.ValueListItems.Add("内棱");
va3.ValueListItems.Add("取样废");
va3.ValueListItems.Add("内壁伤");
va3.ValueListItems.Add("内鼓包");
va3.ValueListItems.Add("外折");
va3.ValueListItems.Add("外结疤");
va3.ValueListItems.Add("外划伤");
va3.ValueListItems.Add("裂纹");
va3.ValueListItems.Add("靑线");
va3.ValueListItems.Add("轧折");
va3.ValueListItems.Add("碰伤");
va3.ValueListItems.Add("孔洞");
va3.ValueListItems.Add("其他");
}
else if (plineCode.Equals("C010"))
{
va1.ValueListItems.Add("");
va1.ValueListItems.Add("孔洞");
va1.ValueListItems.Add("外折");
va1.ValueListItems.Add("划伤");
va1.ValueListItems.Add("内伤");
va1.ValueListItems.Add("误报");
va2.ValueListItems.Add("");
va2.ValueListItems.Add("孔洞");
va2.ValueListItems.Add("外折");
va2.ValueListItems.Add("内伤");
va3.ValueListItems.Add("");
va3.ValueListItems.Add("孔洞");
va3.ValueListItems.Add("外折");
va3.ValueListItems.Add("内伤");
va4.ValueListItems.Add("");
va4.ValueListItems.Add("孔洞");
va4.ValueListItems.Add("外折");
va4.ValueListItems.Add("划伤");
va4.ValueListItems.Add("内伤");
va4.ValueListItems.Add("误报");
//this.ultraGridDetailDes2.DisplayLayout.Bands[0].Columns["REASON1"].Hidden = true;
}
}
this.ultraGridDetailDes1.DisplayLayout.Bands[0].Columns["REASON"].ValueList = va1;
this.ultraGridDetailDes2.DisplayLayout.Bands[0].Columns["REASON"].ValueList = va2;
// this.ultraGridDetailDes3.DisplayLayout.Bands[0].Columns["REASON"].ValueList = va3;
this.ultraGridDetailDes2.DisplayLayout.Bands[0].Columns["REASON1"].ValueList = va4;
}
///
/// 查询可疑品、剔除品
///
public void doQuery()
{
dataTable1.Clear();
dataTable2.Clear();
dataTable3.Clear();
//查询可疑支数
//DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.doQueryAlarmNum", new object[] { heatPlanNo,resultNo }, ob);
//GridHelper.CopyDataToDatatable(ref dt,ref dataTable1,true);
//查询废品支数
//DataTable ds = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchBugD.doQueryScrapNum", new object[] { heatPlanNo, resultNo }, ob);
//GridHelper.CopyDataToDatatable(ref ds, ref dataTable2, true);
//DataTable dd = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQueryOffineNum", new object[] { list }, ob);
//GridHelper.CopyDataToDatatable(ref dd, ref dataTable3, true);
//下拉选探伤废品原因
DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerybase", new object[] { "7004" }, this.ob);
//comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
kreason.DataSource = dt2;
kreason.DisplayMember = "BASENAME";
kreason.ValueMember = "BASECODE";
YdmBaseClass.SetComboItemHeight(kreason);
reason.DataSource = dt2;
reason.DisplayMember = "BASENAME";
reason.ValueMember = "BASECODE";
YdmBaseClass.SetComboItemHeight(reason);
foreach (UltraGridRow urg in ultraGridDetailDes1.Rows)
{
GridEdite(urg);
}
foreach (UltraGridRow urg in ultraGridDetailDes2.Rows)
{
GridEdite(urg);
}
}
private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
this.ultraGridDetailDes1.UpdateData();
GridEdite(e.Cell.Row);
//UltraGrid ug = (UltraGrid)sender;
//this.ultraGridDetailDes1.UpdateData();
//if (e.Cell.Column.Key == "REASON")
//{
// if (e.Cell.Value == "")
// {
// MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// int temp = 0;
// //for (int i = 0; i < ug.Rows.Count(); i++)
// //{
// // UltraGridRow ugr = ug.Rows[i];
// // if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
// // {
// // temp = temp + 1;
// // }
// //}
// //if (temp > 1)
// //{
// // MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// // e.Cell.Row.Cells["REASON"].Value = "";
// //}
//}
//if(e.Cell.Column.Key == "ACT_COUNT")
//{
// int total = 0;
// foreach(UltraGridRow row in this.ultraGridDetailDes1.Rows)
// {
// if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
// {
// total = total + int.Parse(row.Cells["ACT_COUNT"].Value.ToString3());
// }
// }
// ultraGrid1.BeginUpdate();
// foreach (UltraGridRow uRow in this.ultraGrid1.Rows)
// {
// if (total >= uRow.Index + 1)
// {
// uRow.Cells["CHK1"].Value = true;
// }
// else
// {
// uRow.Cells["CHK1"].Value = false;
// }
// }
// ultraGrid1.EndUpdate();
//}
}
private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e)
{
this.ultraGridDetailDes2.UpdateData();
GridEdite(e.Cell.Row);
//UltraGrid ug = (UltraGrid)sender;
//this.ultraGridDetailDes2.UpdateData();
//if (e.Cell.Column.Key == "REASON")
//{
// if (e.Cell.Value == "")
// {
// MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// int temp = 0;
// for (int i = 0; i < ug.Rows.Count(); i++)
// {
// UltraGridRow ugr = ug.Rows[i];
// if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2()))
// {
// temp = temp + 1;
// }
// }
// if (temp > 1)
// {
// MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// e.Cell.Row.Cells["REASON"].Value = "";
// }
//}
//if (e.Cell.Column.Key == "REASON1")
//{
// if (e.Cell.Value == "")
// {
// MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// int temp1 = 0;
// for (int i = 0; i < ug.Rows.Count(); i++)
// {
// UltraGridRow ugr = ug.Rows[i];
// if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2()))
// {
// temp1 = temp1 + 1;
// }
// }
// if (temp1 > 1)
// {
// MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// e.Cell.Row.Cells["REASON"].Value = "";
// }
//}
//if (e.Cell.Column.Key == "ACT_COUNT")
//{
// int total = 0;
// foreach (UltraGridRow row in this.ultraGridDetailDes2.Rows)
// {
// if (Convert.ToBoolean(row.Cells["CHK"].Text) == true)
// {
// total = total + int.Parse(row.Cells["ACT_COUNT"].Value.ToString3());
// }
// }
// ultraGrid1.BeginUpdate();
// IQueryable checkAlarmRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK1 = 'True' and CHK3 = 'False' ORDER BY TO_NUMBER(SEQ) ASC");
// if (checkAlarmRows.Count() < total)
// {
// MessageUtil.ShowTips("废品总支数不能大于报警总支数");
// return;
// }
// else
// {
// int i = 1;
// foreach (UltraGridRow uRow in checkAlarmRows)
// {
// uRow.Cells["CHK2"].Value = false;
// if (i <= total)
// {
// uRow.Cells["CHK2"].Value = true;
// }
// i++;
// }
// }
// ultraGrid1.EndUpdate();
//}
}
private void FrmScrap_FormClosing(object sender, FormClosingEventArgs e)
{
UltraGridRow urg = ultraGridDetailDes2.ActiveRow;
if (urg != null)
{
if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["DEF_FILL_NAME"].Text != "")
{
if (save == "0")
{
MessageUtil.ShowTips("请点保存按钮!");
e.Cancel = true;
}
}
}
}
///
///
/// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
///
///
private void GridEdite(UltraGridRow row)
{
if (row.GetValue("CHK") == "True")
{
foreach (UltraGridCell cell in row.Cells)
{
if (cell.Column.CellActivation == Activation.AllowEdit)
{
cell.Activation = Activation.AllowEdit;
}
}
}
else
{
foreach (UltraGridCell cell in row.Cells)
{
if (cell.Column.Key.Contains("CHK")) continue;
if (cell.Column.CellActivation == Activation.AllowEdit)
{
cell.Activation = Activation.ActivateOnly;
}
}
}
ultraGridDetailDes1.UpdateData();
ultraGridDetailDes2.UpdateData();
}
private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
{
this.ultraGridDetailDes1.UpdateData();
GridEdite(e.Row);
}
private void ultraGridDetailDes2_AfterRowInsert(object sender, RowEventArgs e)
{
this.ultraGridDetailDes2.UpdateData();
GridEdite(e.Row);
}
//private void ultraGridDetailDes3_CellChange(object sender, CellEventArgs e)
//{
// UltraGrid ug = (UltraGrid)sender;
// this.ultraGridDetailDes3.UpdateData();
// if (e.Cell.Column.Key == "REASON")
// {
// if (e.Cell.Value == "")
// {
// MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// int temp = 0;
// for (int i = 0; i < ug.Rows.Count(); i++)
// {
// UltraGridRow ugr = ug.Rows[i];
// if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
// {
// temp = temp + 1;
// }
// }
// if (temp > 1)
// {
// MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// e.Cell.Row.Cells["REASON"].Value = "";
// }
// }
//}
//private void FrmScrap_Leave(object sender, EventArgs e)
//{
// FrmTestingResult frmTestingResult = new FrmTestingResult();
// frmTestingResult.ETResultSave();
//}
}
}