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.Server;
using Core.Mes.Client.Comm.Control;
using Infragistics.Win.UltraWinGrid;
using System.Collections;
using com.steering.mes.mcp.entity;
using Core.StlMes.Client.Mcp.Common;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.Mcp;
using Core.StlMes.Client.Mcp.CollarMaterial;
using Core.StlMes.Client.Mcp.Control;
using Core.StlMes.Client.Mcp.Entity;
using Core.StlMes.Client.Mcp.BaseMethod;
using Core.StlMes.Client.Mcp.Coupling;
using Core.StlMes.Client.Mcp.Report;
namespace Core.StlMes.Client.Coup
{
public partial class FrmCoupLoading : FrmBase
{
private string departm="";//获取部门ID
private string[] plineCode = null;//获取产线代码
private string SlGx = "";//上料工序
private string SLGxName = "";//上料名称
public string LiXian = "";
private string StrMemo = "";//备注
private string[] plineCodes;
public FrmCoupLoading()
{
InitializeComponent();
this.IsLoadUserView = true;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//禁控件过滤
// this.coupWoIdPlanControl1.Grid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
// //设置计划区控件只读
////this.coupWoIdPlanControl1.SetAllColumnsActiveOnly();
//coupWoIdPlanControl1.Ob = this.ob;
}
///
/// 初始化页面
///
///
///
private void FrmCoupLoading_Load(object sender, EventArgs e)
{
EntityHelper.ShowGridCaption(ultraGridWoId.DisplayLayout.Bands[0]);
EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]);
EntityHelper.ShowGridCaption(ultraGridLoad.DisplayLayout.Bands[0]);
departm = UserInfo.GetDeptid();
//plineCode = McpBaseHelper.GetPCodePline(departm,this.ob);
plineCodes = comm.GetPlineCode(this.ValidDataPurviewIds, "H", ob);
//获取工序
DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.common.PlanService.getQueryGX", new object[] { "700301" }, this.ob);
if (dt2.Rows.Count > 0)
{
SlGx = dt2.Rows[0]["BASECODE"].ToString();
SLGxName = dt2.Rows[0]["BASENAME"].ToString();
}
ProTime.Value = DateTime.Today;
txtBC.Value = this.UserInfo.GetUserOrder();
txtBz.Value = this.UserInfo.GetUserGroup();
txtUser.Text = this.UserInfo.GetUserName();
BaseHelper.setOtherColumnReadOnly(ultraGridWoId, new string[] { "CHC", "CraftNoJg2" });
BaseHelper.setUltraGridColumnMaxInput(ultraGridWoId, new string[] { "PlanBlWt", "RealBlWt", "OutWt" });
BaseHelper.setUltraGridColumnBits(ultraGridWoId, new string[] { "PlanJgNum", "CsJgNum", "XqJgNum", "PlanBlNum", "RealBlNum", "OutNum" });
BaseHelper.InitCellPosition(ultraGridWoId, new string[] { "PlanBlWt", "RealBlWt", "OutWt", "PlanJgNum", "CsJgNum", "XqJgNum", "PlanBlNum", "RealBlNum", "OutNum" });
BaseHelper.GridColumnSum(ultraGridWoId, new string[] { "PlanBlWt", "RealBlWt", "OutWt" });
BaseHelper.GridColumnCount(ultraGridWoId, new string[] { "PlanJgNum", "CsJgNum", "XqJgNum", "PlanBlNum", "RealBlNum", "OutNum" });
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
QuerySinglePlan();
break;
case "Save":
Save();
break;
case "Delete":
DoDelete();
break;
case"Back"://回库
doBack();
break;
case "CancelBack"://撤销回库
CancelBack();
break;
case "Offline"://离线
Offline();
break;
case "unOffline":
unOffline();
break;
case "DoBeside"://结炉
DoBeside();
break;
case "UndoBeside"://撤销结炉
UndoBeside();
break;
case "Confirm":
confirm();//确认
break;
case"CancelConfirm":
cancelConfirm();
break;
case "Print":
Print();
break;
case "Close":
this.Close();
break;
}
}
///
/// 打印收料单
///
private void Print()
{
this.ultraGridWoId.UpdateData();
UltraGridRow uRow = this.ultraGridWoId.ActiveRow;
if (uRow == null) return;
string woId = uRow.Cells["WoId"].Text.Trim();
string strurl = "";
strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepJgConsignationForm.cpt" + "&WO_ID=" + woId;
FrmRepExcel fBug = new FrmRepExcel(ob, strurl);
fBug.AutoSize = true;
fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fBug.WindowState = FormWindowState.Maximized;
fBug.Text = "收料单";
fBug.Show();
}
///
/// 取消确认
///
private void cancelConfirm()
{
ultraGridLoad.UpdateData();
UltraGridRow uRow = this.ultraGridLoad.ActiveRow;
if (uRow == null) { MessageUtil.ShowTips("无上料实绩!"); return; }
UltraGridRow row = this.ultraGridWoId.ActiveRow;
if (row == null)
{
MessageUtil.ShowTips("无工单信息,不允许此操作!");
}
ArrayList list1 = new ArrayList();
int UpdaCount = 0;
foreach (UltraGridRow ugr in ultraGridLoad.Rows)
{
if (Convert.ToBoolean(ugr.Cells["CHECK"].Text) == true)
{
if (ugr.Cells["Confirm"].Value.ToString().Equals("0"))
{
MessageUtil.ShowTips("选中有没确认实绩,不允许取消确认!");
return;
}
UpdaCount += 1;
ArrayList list = new ArrayList();
list.Add(ugr.Cells["ResultNo"].Text.ToString());
list.Add(UserInfo.GetUserName());
list.Add(DateTime.Now.ToString());
list1.Add(list);
}
}
if (UpdaCount == 0) { MessageUtil.ShowTips("请选择上料实绩数据!"); return; }
if (MessageUtil.ShowYesNoAndQuestion("是否取消确认上料实绩?") == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam();
try
{
this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
if (Constant.WaitingForm == null)
{
Constant.WaitingForm = new WaitingForm();
}
Constant.WaitingForm.ShowToUser = true;
Constant.WaitingForm.Show();
Constant.WaitingForm.Update();
ccp.ServerName = "com.steering.mes.mcp.coup.CoupLoadingService";
ccp.MethodName = "getCancelConfirm";
ccp.ServerParams = new object[] { list1 };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
catch (Exception ex)
{
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("取消确认成功!"))
{
QuerySinglePlan();
}
}
}
///
/// 确认
///
private void confirm()
{
ultraGridLoad.UpdateData();
UltraGridRow uRow = this.ultraGridLoad.ActiveRow;
if (uRow == null) { MessageUtil.ShowTips("无上料实绩!"); return; }
UltraGridRow row = this.ultraGridWoId.ActiveRow;
if (row == null)
{
MessageUtil.ShowTips("无工单信息,不允许此操作!");
}
ArrayList list1 = new ArrayList();
int UpdaCount = 0;
foreach (UltraGridRow ugr in ultraGridLoad.Rows)
{
if (Convert.ToBoolean(ugr.Cells["CHECK"].Text) == true)
{
if (ugr.Cells["Confirm"].Value.ToString().Equals("1"))
{
MessageUtil.ShowTips("选中有已确认实绩,不允许再次确认!");
return;
}
UpdaCount += 1;
ArrayList list = new ArrayList();
list.Add(ugr.Cells["ResultNo"].Text.ToString());
list.Add(UserInfo.GetUserName());
list.Add(DateTime.Now.ToString());
list1.Add(list);
}
}
if (UpdaCount == 0) { MessageUtil.ShowTips("请选择上料实绩数据!"); return; }
if (MessageUtil.ShowYesNoAndQuestion("是否确认上料实绩?") == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam();
try
{
this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
if (Constant.WaitingForm == null)
{
Constant.WaitingForm = new WaitingForm();
}
Constant.WaitingForm.ShowToUser = true;
Constant.WaitingForm.Show();
Constant.WaitingForm.Update();
ccp.ServerName = "com.steering.mes.mcp.coup.CoupLoadingService";
ccp.MethodName = "getConfirm";
ccp.ServerParams = new object[] { list1 };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
catch (Exception ex)
{
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("确认成功!"))
{
QuerySinglePlan();
}
}
}
///
/// 离线
///
private void Offline()
{
string _strat = "";
UltraGridRow row = ultraGridWoId.ActiveRow;
if (row == null) return;
if (row.Cells["ZyBillStatus"].Value.ToString() == "生产完成")
{
MessageUtil.ShowTips("此炉次计划整体已生产完成,不允许此操作!");
return;
}
if (row.Cells["FeedHeatNo"].Text.ToString() == "A21032378")
{
MessageUtil.ShowTips("天淮来料离线需要测试,请联系视拓!");
return;
}
if (row.Cells["FeedHeatNo"].Text.ToString() == "A21032381")
{
MessageUtil.ShowTips("天淮来料离线需要测试,请联系视拓!");
return;
}
if (row.Cells["FeedHeatNo"].Text.ToString() == "A21032548")
{
MessageUtil.ShowTips("天淮来料离线需要测试,请联系视拓!");
return;
}
UltraGridRow row1 = ultraGridLoad.ActiveRow;
if (row1 == null)
{
MessageUtil.ShowTips("没有上料实绩不能离线!");
return;
}
OffLine frm = new OffLine();
frm.ShowDialog();
LiXian = frm.StrNum;
_strat = frm.Strat;
StrMemo = frm.StrMemo;
if (_strat.Equals("")) return;
if (LiXian.Equals("") || LiXian.Equals("0")) { MessageUtil.ShowTips("离线支数不能为空!"); return; }
//查询上料实绩支数总和
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.coup.CoupLoadingService.getLoadResult1", new object[] { row.Cells["WoId"].Value.ToString() }, this.ob);
string pronum = "";
if (dt.Rows.Count > 0)
{
pronum = dt.Rows[0]["PRO_NUM"].ToString();
}
else
{
pronum = "0";
}
string woId = row.Cells["WoId"].Value.ToString();
if (row1.Cells["OffNum"].Value.ToString() == "")
{
row1.Cells["OffNum"].Value = "0";
}
if (int.Parse(pronum) < int.Parse(LiXian) + int.Parse(offlinePiece.Value.ToString()))
{
MessageUtil.ShowTips("离线支数不能大于上料支数!");
return;
}
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
ArrayList list = new ArrayList();
list.Add(LiXian);
list.Add(row.Cells["WoId"].Text.ToString());
list.Add(row.Cells["HeatPlanNo"].Text.ToString());
list.Add(row.Cells["JudgeStoveNo"].Text.ToString());
list.Add(row.Cells["BatchNo"].Text.ToString());
list.Add(row.Cells["PlineCode"].Text.ToString());
list.Add(row.Cells["PlineName"].Text.ToString());
list.Add(this.UserInfo.GetUserName());
list.Add(this.UserInfo.GetUserOrder());
list.Add(this.UserInfo.GetUserGroup());
list.Add(time);
list.Add(row1.Cells["ResultNo"].Value.ToString());
list.Add(StrMemo);
list.Add(row.Cells["BatchGroudNo"].Value.ToString());
list.Add(row.Cells["FeedHeatNo"].Text.ToString());
CoreClientParam ccp = new CoreClientParam();
try
{
this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
if (Constant.WaitingForm == null)
{
Constant.WaitingForm = new WaitingForm();
}
Constant.WaitingForm.ShowToUser = true;
Constant.WaitingForm.Show();
Constant.WaitingForm.Update();
ccp.ServerName = "com.steering.mes.mcp.coup.CoupCutService";
ccp.MethodName = "lixianThreadingResult";
ccp.ServerParams = new object[] { list, SlGx, SLGxName };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
catch (Exception ex)
{
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("离线成功!"))
{
QuerySinglePlan();
// DoClean();
}
}
}
///
/// 撤销离线
///
private void unOffline()
{
ultraGrid2.UpdateData();
UltraGridRow uRow = this.ultraGrid2.ActiveRow;
if (uRow == null) { MessageUtil.ShowTips("切管实绩无数据!"); return; }
UltraGridRow row = this.ultraGridWoId.ActiveRow;
if (uRow == null)
{
MessageUtil.ShowTips("无工单信息,不允许此操作!");
}
if (row.Cells["ZyBillStatus"].Value.ToString() == "生产完成")
{
MessageUtil.ShowTips("此炉次计划整体已生产完成,不允许此操作!");
return;
}
string woId = row.Cells["WoId"].Value.ToString();
ArrayList list1 = new ArrayList();
int UpdaCount = 0;
foreach (UltraGridRow ugr in ultraGridLoad.Rows)
{
if (Convert.ToBoolean(ugr.Cells["CHECK"].Text) == true)
{
UpdaCount += 1;
ArrayList list = new ArrayList();
list.Add(ugr.Cells["ResultNo"].Text.ToString());
list.Add(ugr.Cells["OffNum"].Text.ToString());
list1.Add(list);
}
}
if (UpdaCount == 0) { MessageUtil.ShowTips("请选择离线数据!"); return; }
if (MessageUtil.ShowYesNoAndQuestion("是否撤销离线?") == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam();
try
{
this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
if (Constant.WaitingForm == null)
{
Constant.WaitingForm = new WaitingForm();
}
Constant.WaitingForm.ShowToUser = true;
Constant.WaitingForm.Show();
Constant.WaitingForm.Update();
ccp.ServerName = "com.steering.mes.mcp.coup.CoupCutService";
ccp.MethodName = "unlixianThreadingResult";
ccp.ServerParams = new object[] { list1, row.Cells["WoId"].Text.ToString(), SlGx };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
catch (Exception ex)
{
this.Cursor = Cursors.Default;
Constant.WaitingForm.ShowToUser = false;
Constant.WaitingForm.Close();
Constant.WaitingForm = null;
}
if (ccp.ReturnCode == -1) return;
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("撤销离线成功!"))
{
QuerySinglePlan();
}
}
///
/// 结炉
///
private void DoBeside()
{
UltraGridRow uRow = this.ultraGridWoId.ActiveRow;
if (uRow == null)
{
MessageUtil.ShowTips("请选择需要结炉的工单号!");
return;
}
//查询上料实绩支数总和
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.coup.CoupLoadingService.getLoadResult1", new object[] { uRow.Cells["WoId"].Value.ToString() }, this.ob);
string pronum = "";
if (dt.Rows.Count > 0)
{
pronum = dt.Rows[0]["PRO_NUM"].ToString();
}
else
{
pronum = "0";
}
UltraGridRow Row = this.ultraGrid2.ActiveRow;
if(Row!=null)
{
if (Convert.ToInt32(uRow.Cells["PlanBlNum"].Value) > Convert.ToInt32(pronum))
{
MessageUtil.ShowTips("上料支数的和不能小于计划支数!");
return;
}
}
string woId = uRow.Cells["WoId"].Value.ToString();
if (MessageUtil.ShowYesNoAndQuestion("是否结炉?") == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.coup.CoupLoadingService";
ccp.MethodName = "doBeside";
ccp.ServerParams = new object[] { SlGx, woId };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("结炉成功!"))
{
QuerySinglePlan();
}
}
}
///
/// 撤销结炉
///
private void UndoBeside()
{
UltraGridRow uRow = this.ultraGridWoId.ActiveRow;
if (uRow == null)
{
MessageUtil.ShowTips("请选择需要撤销结炉的工单号!");
return;
}
//string zYgNo = uRow.Cells["ZY_PLAN_ID"].Value.ToString();
string woId = uRow.Cells["WoId"].Value.ToString();
//DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.PlanService.getQueryWoIdDetails", new object[] { woId, zYgNo }, this.ob);
//if (!dt.Rows[0]["CUT_STATUS"].ToString().Equals("生产完成"))
//{
// MessageUtil.ShowTips("此工单工序点未结炉,不允许此操作!");
// return;
//}
//if (dt.Rows[0]["ZY_BILL_STATUS"].ToString().Equals("生产完成"))
//{
// MessageUtil.ShowTips("此工单状态生产完成,不允许此操作!");
// return;
//}
if (MessageUtil.ShowYesNoAndQuestion("是否撤销结炉?") == DialogResult.No)
{
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.mes.mcp.coup.CoupLoadingService";
ccp.MethodName = "undoBeside";
ccp.ServerParams = new object[] { SlGx, woId };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("撤销结炉成功!"))
{
QuerySinglePlan();
}
}
}
///
/// 简单查询
///
private void QuerySinglePlan()
{
string woId = "";
string[] starts = { };
string judgeStoveNo = "";
string plnNo = "";
#region 条件
if (chkStarts.Checked)
{
if (string.IsNullOrEmpty(cmbStarts.Text.Trim()))
{
MessageUtil.ShowTips("请选择工单状态!");
return;
}
else
{
starts = (cmbStarts.Value as List