using Core.Mes.Client.Comm.Format;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.YdmStuffManage.Entity;
using CoreFS.CA06;
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.Net;
using System.Text;
using System.Windows.Forms;
namespace Core.StlMes.Client.YdmStuffManage
{
public partial class FrmStuffSurfaceResult : FrmBase
{
public FrmStuffSurfaceResult()
{
InitializeComponent();
//surfaceResult1.initValue();
}
private StlLgSurfaceM1Entity qcmSurfaceM = new StlLgSurfaceM1Entity();//表检实绩信息
private string PlineCode = "";//产线
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "DoQuery":
QuerySinglePlan();
break;
case "Save":
SaveData();
break;
case "DoBeside":
doBeside();
break;
case "DoBesideBack":
doBesideBack();
break;
case "BatchScrapNum":
batchScrapNum();
break;
case "BatchOffNum":
batchOffNum();
break;
case "BatchSaveReason":
batchSaveReason();
break;
case "ClearReason":
clearReason();
break;
case "printSuface":
printSuface();
break;
case"upLoadSuface":
upLoadSuface();
break;
case "Close":
this.Close();
break;
}
}
///
/// 清空缺陷原因
///
private void clearReason()
{
this.ultraGrid1.UpdateData();
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
PlnSteelforOrdEntity plnSteelTity = (PlnSteelforOrdEntity)uRow.ListObject;
string plnSteelEntity = JSONFormat.Format(plnSteelTity);
ArrayList list = new ArrayList();
list.Add(plnSteelTity.Furnaceno);
list.Add(plnSteelTity.Sequenceno);
list.Add(plnSteelTity.StoveNo);
list.Add(plnSteelTity.JudgeStoveNoSeq);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "clearReason";
ccp.ServerParams = new object[] { plnSteelEntity };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("清空成功!"))
{
doQueryRack(list);
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 保存缺陷原因
///
private void batchSaveReason()
{
this.ultraGrid1.UpdateData();
string scrapNum = "";
string scrapReson = "";//缺陷原因
if (this.TxtScrapNum.Text.Trim() != "" && StringUtil.IsInt(this.TxtScrapNum.Text.Trim()))
{
scrapNum = this.TxtScrapNum.Text.Trim();
}
else
{
MessageUtil.ShowTips("批量剔除时请输入支数并且为整数!");
return;
}
if (this.TxtScrapNum.Text.Trim() != "")
{
scrapReson = this.ultraComboEditor1.Text.Trim();
}
else
{
MessageUtil.ShowTips("批量剔除时请选择废品原因!");
return;
}
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
PlnSteelforOrdEntity plnSteelTity = (PlnSteelforOrdEntity)uRow.ListObject;
string plnSteelEntity = JSONFormat.Format(plnSteelTity);
ArrayList list = new ArrayList();
list.Add(plnSteelTity.Furnaceno);
list.Add(plnSteelTity.Sequenceno);
list.Add(plnSteelTity.StoveNo);
list.Add(plnSteelTity.JudgeStoveNoSeq);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "batchSaveReason";
ccp.ServerParams = new object[] { plnSteelEntity, scrapNum, scrapReson };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("保存成功!"))
{
doQueryRack(list);
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 批量剔除
///
private void batchScrapNum()
{
this.ultraGrid1.UpdateData();
string scrapNum = "";
string scrapReson = "";//废品原因
string okNum = "";
if (this.TxtScrapNum.Text.Trim() != "" && StringUtil.IsInt(this.TxtScrapNum.Text.Trim()))
{
scrapNum = this.TxtScrapNum.Text.Trim();
}
else
{
MessageUtil.ShowTips("批量剔除时请输入支数并且为整数!");
return;
}
if (this.TxtScrapNum.Text.Trim() != "")
{
scrapReson = this.ultraComboEditor1.Text.Trim();
}
else
{
MessageUtil.ShowTips("批量剔除时请选择废品原因!");
return;
}
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
//if (uRow.HasChild())
//{
// return;
//}
PlnSteelforOrdEntity plnSteelTity = (PlnSteelforOrdEntity)uRow.ListObject;
string plnSteelEntity = JSONFormat.Format(plnSteelTity);
DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryOkNum", new object[] { plnSteelEntity }, ob);//查询合格坯料支数
if (ds.Rows.Count > 0)
{
okNum = ds.Rows[0][0].ToString();
}
if (int.Parse(scrapNum) > int.Parse(okNum))
{
MessageUtil.ShowTips("输入的批量剔除支数已大于合格支数,不允许批量剔除!");
return;
}
ArrayList list = new ArrayList();
list.Add(plnSteelTity.Furnaceno);
list.Add(plnSteelTity.Sequenceno);
list.Add(plnSteelTity.StoveNo);
list.Add(plnSteelTity.JudgeStoveNoSeq);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "batchScrapNum";
ccp.ServerParams = new object[] { plnSteelEntity,scrapNum,scrapReson };
ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("剔除成功!"))
{
doQueryRack(list);
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 批量离线
///
private void batchOffNum()
{
this.ultraGrid1.UpdateData();
string scrapNum = "";
string scrapReson = "";//废品原因
string okNum = "";
if (this.TxtScrapNum.Text.Trim() != "" && StringUtil.IsInt(this.TxtScrapNum.Text.Trim()))
{
scrapNum = this.TxtScrapNum.Text.Trim();
}
else
{
MessageUtil.ShowTips("批量离线时请输入支数并且为整数!");
return;
}
if (this.TxtScrapNum.Text.Trim() != "")
{
scrapReson = this.ultraComboEditor1.Text.Trim();
}
else
{
MessageUtil.ShowTips("批量剔除时请选择废品原因!");
return;
}
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
//if (uRow.HasChild())
//{
// return;
//}
PlnSteelforOrdEntity plnSteelTity = (PlnSteelforOrdEntity)uRow.ListObject;
string plnSteelEntity = JSONFormat.Format(plnSteelTity);
DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryOkNum", new object[] { plnSteelEntity }, ob);//查询合格坯料支数
if (ds.Rows.Count > 0)
{
okNum = ds.Rows[0][0].ToString();
}
if (int.Parse(scrapNum) > int.Parse(okNum))
{
MessageUtil.ShowTips("输入的批量离线支数已大于合格支数,不允许批量离线!");
return;
}
ArrayList list = new ArrayList();
list.Add(plnSteelTity.Furnaceno);
list.Add(plnSteelTity.Sequenceno);
list.Add(plnSteelTity.StoveNo);
list.Add(plnSteelTity.JudgeStoveNoSeq);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "batchOffNum";
ccp.ServerParams = new object[] { plnSteelEntity, scrapNum, scrapReson, UserInfo.GetUserName(), UserInfo.GetUserOrder(), UserInfo.GetUserGroup() };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("离线成功!"))
{
doQueryRack(list);
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 上传PDF表检报告
///
private void upLoadSuface()
{
string filePathNew = ""; //表检报告目录
WebClient webClient = new WebClient();
List listPdf = new List();
string date = DateTime.Now.ToString("yyyyMMdd");
string judgeNo = "";
string proPlanId = "";
string gxPlanNo = "";
string plineCode = "";
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
if (uRow == null)
{
return;
}
judgeNo = uRow.Cells["JudgeStoveNo"].Text;
proPlanId = uRow.Cells["ProPlanId"].Text;
gxPlanNo = uRow.Cells["GxPlanNo"].Text;
plineCode = uRow.Cells["PlineCode"].Text;
string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepLgCastingInspectionRecord.cpt&format=pdf&JUDGE_STOVE_NO=" + judgeNo + "&PRO_PLAN_ID=" + proPlanId + "&GX_PLAN_NO=" + gxPlanNo;
filePathNew = "LgMil/surfcacReprot"+"/"+ plineCode + "/" + judgeNo + "/";
byte[] pdf = webClient.DownloadData(url);
FileBean fileBean = new FileBean();
fileBean.setFile(pdf);
fileBean.setFileName(proPlanId.Replace("/","-")+judgeNo + ".pdf");
fileBean.setPathName(filePathNew);
listPdf.Add(fileBean);
webClient.Dispose();
bool a = FileHelper.Upload(listPdf);
if (a)
{
int count = ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.updateSurFace", new object[] { filePathNew, judgeNo, proPlanId, gxPlanNo }, ob);
if (count > 0)
{
MessageUtil.ShowTips("上传成功!");
SelectFile(filePathNew + proPlanId.Replace("/", "-") + judgeNo + ".pdf");
}
}
}
///
/// 查询上传的PDF文件
///
private void SelectFile(string filePathNew)
{
dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathNew);
down.DeleteButton.Visible = false;
down.ShowDialog();
}
///
/// 打印表检报告
///
private void printSuface()
{
string judgeNo = "";
string proPlanId = "";
string gxPlanNo = "";
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
if (uRow == null)
{
return;
}
judgeNo = uRow.Cells["JudgeStoveNo"].Text;
proPlanId = uRow.Cells["ProPlanId"].Text;
gxPlanNo = uRow.Cells["GxPlanNo"].Text;
string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepLgCastingInspectionRecord.cpt&format=pdf&JUDGE_STOVE_NO=" + judgeNo + "&PRO_PLAN_ID=" + proPlanId + "&GX_PLAN_NO=" + gxPlanNo;
FrmExcel fre = new FrmExcel(this.ob, strurl);
fre.AutoSize = true;
fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fre.WindowState = FormWindowState.Maximized;
fre.Show();
}
///
/// 查询炉计划
///
private void QuerySinglePlan()
{
string[] L1 = new string[] { "Furnaceno", "StoveNo" };
string[] L2 = new string[] { "Furnaceno","StoveNo" };
string startTim = "";
string endTim = "";
string stoveNo = "";
if (this.chkRegTime.Checked)
{
startTim = this.RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
endTim = this.RegEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
}
if (this.chkFurnace.Checked && this.txtFurnace.Text.Trim() != "")
{
stoveNo = this.txtFurnace.Text.Trim();
}
StlLgSurfaceMEntitybindingSource.Clear();
StlLgProgrrssEntitybindingSource.Clear();
// List listSource = EntityHelper.GetData(
//"Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlanStoveNo", new object[] { startTim, endTim, stoveNo,this.ultraOptionSet2.CheckedItem.DataValue.ToString(), arr,"0" }, this.ob);
List listSource1 = EntityHelper.GetData(
"Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlan", new object[] { startTim, endTim, stoveNo, this.ultraOptionSet2.CheckedItem.DataValue.ToString(), arr,"0" }, this.ob);
//EntityHelper.AddEntityRelation(listSource, listSource1, L1, L2);
plnSteelforOrdEntity1BindingSource.DataSource = listSource1;
}
///
/// 保存
///
private void SaveData()
{
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
//if (uRow.HasChild())
//{
// return;
//}
if (uRow == null)
{
MessageUtil.ShowTips("无炉计划信息,无法保存!");
return;
}
this.surfaceResult1.UltraGrid2.UpdateData();
qcmSurfaceM = BaseMethod.GetUltraGridToEntityNEW(this.surfaceResult1.UltraGrid2,qcmSurfaceM);
qcmSurfaceM.Furnaceno = uRow.Cells["Furnaceno"].Text;
qcmSurfaceM.Sequenceno = uRow.Cells["Sequenceno"].Text;
qcmSurfaceM.StoveNo = uRow.Cells["StoveNo"].Text;
qcmSurfaceM.JudgeStoveNo = uRow.Cells["JudgeStoveNo"].Text;
qcmSurfaceM.JudgeStoveNoSeq = uRow.Cells["JudgeStoveNoSeq"].Text;
qcmSurfaceM.ProPlanId = uRow.Cells["ProPlanId"].Text;
qcmSurfaceM.GxPlanNo = uRow.Cells["GxPlanNo"].Text;
qcmSurfaceM.ColGroup = UserInfo.GetUserGroup();
qcmSurfaceM.ColShift = UserInfo.GetUserOrder();
qcmSurfaceM.PlineCode = PlineCode;
//string qcmSurfaceMS = JSONFormat.Format(qcmSurfaceM);
//qcmSurfaceM.PlineCode = "C001";
//DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryStausSum", new object[] { qcmSurfaceMS, "0" }, ob);
//qcmSurfaceM.Quantity = ds.Rows[0][0].ToString();
//DataTable dd = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryStausSum", new object[] { qcmSurfaceMS, "1" }, ob);
//qcmSurfaceM.ScrapNum = dd.Rows[0][0].ToString();
//DataTable df = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryStausSum", new object[] { qcmSurfaceMS, "2" }, ob);
//qcmSurfaceM.OfflineNum = df.Rows[0][0].ToString();
//DataTable dh = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryStausSum", new object[] { qcmSurfaceMS, "3" }, ob);
//qcmSurfaceM.Eligiblequty = dh.Rows[0][0].ToString();
//qcmSurfaceM.ActWeight = decimal.Parse(dh.Rows[0][1].ToString());
qcmSurfaceM.CreateName = UserInfo.GetUserName();
string qcmSurfaceMTity = JSONFormat.Format(qcmSurfaceM);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "saveSurfaceResult";
ccp.ServerParams = new object[] { qcmSurfaceMTity};
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("保存成功!"))
{
QuerySinglePlan();
MessageUtil.ShowTips(ccp.ReturnInfo);
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
///
/// 结炉
///
private void doBeside()
{
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
if (uRow == null) return;
//if (uRow.HasChild())
//{
// return;
//}
ArrayList list = new ArrayList();
list.Add(uRow.Cells["Furnaceno"].Text);
list.Add(uRow.Cells["Sequenceno"].Text);
list.Add(uRow.Cells["StoveNo"].Text);
list.Add(uRow.Cells["JudgeStoveNoSeq"].Text);
//DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryOffline", new object[] { list }, ob);
//if (int.Parse(ds.Rows[0][0].ToString()) > 0)
//{
// MessageUtil.ShowTips("还存在待处理坯子,不允许结炉!");
// return;
//}
DataTable dd = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlnSteeOrd", new object[] { list }, ob);
if (!dd.Rows[0]["CCM_STATE"].ToString().Equals("10"))
{
MessageUtil.ShowTips("执行状态不是切割完成,不允许结炉!");
return;
}
SaveData();
int count = ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doBaside", new object[] { list,this.UserInfo.GetUserOrder(),this.UserInfo.GetUserGroup() }, ob);
if (count > 0)
{
QuerySinglePlan();
MessageUtil.ShowTips("结炉成功!");
}
}
///
/// 结炉回退
///
private void doBesideBack()
{
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
if (uRow == null) return;
//if (uRow.HasChild())
//{
// return;
//}
ArrayList list = new ArrayList();
list.Add(uRow.Cells["Furnaceno"].Text);
list.Add(uRow.Cells["Sequenceno"].Text);
list.Add(uRow.Cells["StoveNo"].Text);
list.Add(uRow.Cells["JudgeStoveNoSeq"].Text);
DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlnSteeOrd", new object[] { list }, ob);
if (!ds.Rows[0]["CCM_STATE"].ToString().Equals("20"))
{
MessageUtil.ShowTips("执行状态不是表检完成,不允许结炉回退!");
return;
}
DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryEntrust", new object[] { list }, ob);
if (dt.Rows.Count > 0)
{
MessageUtil.ShowTips("已有进行委外加工委托,不允许结炉回退!");
return;
}
DataTable dd = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryStlLgProcess", new object[] { list }, ob);
if (dd.Rows.Count > 0)
{
MessageUtil.ShowTips("已有进行表检委托,不允许结炉回退!");
return;
}
int count = ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doBasideBack", new object[] { list }, ob);
if (count > 0)
{
QuerySinglePlan();
MessageUtil.ShowTips("结炉回退成功!");
}
}
private void chkFurnace_CheckedChanged(object sender, EventArgs e)
{
this.txtFurnace.Enabled = this.chkFurnace.Checked;
}
private void chkRegTime_CheckedChanged(object sender, EventArgs e)
{
this.RegStartTime.Enabled = this.RegEndTime.Enabled = this.chkRegTime.Checked;
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow uRow = this.ultraGrid1.ActiveRow;
//if (uRow.HasChild())
//{
// return;
//}
if (uRow == null)
{
return;
}
ArrayList list = new ArrayList();
DataTable ds = new DataTable();
ds.Columns.Add("STOVE_NO");
ds.Columns.Add("JUDGE_STOVE_NO");
ds.Columns.Add("FLAG_STOVE_NO");
ds.Columns.Add("MATERIAL_NAME");
ds.Columns.Add("GRADENAME");
ds.Columns.Add("DIAMETER");
ds.Columns.Add("LEN_GP_SINGLE");
ds.Columns.Add("CUT_NUM_GP");
ds.Columns.Add("CAST_NO");
ds.Columns.Add("FLOWNO");
ds.Columns.Add("TOT_MUM_M");
ds.Columns.Add("TOT_WEIGHT_M");
DataRow dr = ds.NewRow();
object[] obj = { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["FlagStoveNo"].Text, uRow.Cells["MaterialName"].Text, uRow.Cells["Gradename"].Text,uRow.Cells["Diameter"].Text, uRow.Cells["LenGpSingle"].Text, uRow.Cells["CutNumGp"].Text, uRow.Cells["CastNo"].Text, uRow.Cells["Flowno"].Text, uRow.Cells["TotMumM"].Text, uRow.Cells["TotWeightM"].Text };
dr.ItemArray = obj;
ds.Rows.Add(dr);
if (ds.Rows.Count > 0)
{
GridEdit(ds);
}
list.Add(uRow.Cells["Furnaceno"].Text);
list.Add(uRow.Cells["Sequenceno"].Text);
list.Add(uRow.Cells["StoveNo"].Text);
list.Add(uRow.Cells["JudgeStoveNoSeq"].Text);
doQuerySurFace(list);
//DataTable resultDt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryResult", new object[] { list }, ob);
//if (resultDt.Rows.Count > 0)
//{
// resultGridEdit(resultDt);
//}
}
private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow uRow = this.ultraGrid3.ActiveRow;
if (uRow == null) return;
ArrayList parm = new ArrayList();
parm.Add(uRow.Cells["Furnaceno"].Text);
parm.Add(uRow.Cells["Sequenceno"].Text);
parm.Add(uRow.Cells["StoveNo"].Text);
parm.Add(uRow.Cells["JudgeStoveNoSeq"].Text);
doQueryRack(parm);//查询管坯队列
}
///
/// 查询表检实绩
///
///
private void doQuerySurFace(ArrayList list)
{
this.surfaceResult1.clear();
StlLgProgrrssEntitybindingSource.Clear();
List listSource = EntityHelper.GetData(
"Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryResult", new object[] { list }, this.ob);
StlLgSurfaceMEntitybindingSource.DataSource = listSource;
if (listSource.Count()>0)
{
this.surfaceResult1.Value = listSource[0];
}
}
private void doQueryRack(ArrayList list)
{
List listSource = EntityHelper.GetData(
"Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryRack", new object[] { list }, this.ob);
StlLgProgrrssEntitybindingSource.DataSource = listSource;
foreach (UltraGridRow ugr in this.ultraGrid2.Rows)
{
if (ugr != null)
{
switch (ugr.Cells["Status"].Value.ToString())
{
case "剔除":
ugr.Appearance.BackColor = Color.Yellow;
break;
case"待处理":
ugr.Appearance.BackColor = Color.YellowGreen;
break;
case"委外废":
ugr.Appearance.BackColor = Color.Yellow;
break;
}
}
}
}
///
/// 显示实绩信息
///
private void resultGridEdit(DataTable resultDt)
{
//QcmLgSurfaceM1Entity qcmSurfaceM = new QcmLgSurfaceM1Entity();
qcmSurfaceM = BaseMethod.GetTableToEntity(resultDt, qcmSurfaceM);
this.surfaceResult1.Value = qcmSurfaceM;
}
///
/// 显示炉信息
///
///
private void GridEdit(DataTable ds)
{
DataRow row = ds.Rows[0];
this.planInfomation1.Value.StoveNo = row["STOVE_NO"].ToString();//熔炼炉号
this.planInfomation1.Value.JudgeStoveNo = row["JUDGE_STOVE_NO"].ToString();//判定炉号
this.planInfomation1.Value.MaterialName = row["MATERIAL_NAME"].ToString();//物料描述
this.planInfomation1.Value.Diameter = row["DIAMETER"].ToString3();//直径
this.planInfomation1.Value.Gradename = row["GRADENAME"].ToString();//钢种
//this.planInfomation1.Value.LengthM = decimal.Parse(row["LENGTH_M"].ToString3());//总长度
this.planInfomation1.Value.LenGpSingle = decimal.Parse(row["LEN_GP_SINGLE"].ToString3());//单倍坯长
this.planInfomation1.Value.CutNumGp = decimal.Parse(row["CUT_NUM_GP"].ToString3());//倍尺数
this.planInfomation1.Value.FlagStoveNo = row["FLAG_STOVE_NO"].ToString();
this.planInfomation1.Value.CastNo = row["CAST_NO"].ToString();
this.planInfomation1.Value.Flowno = row["FLOWNO"].ToString();
this.planInfomation1.Value.TotMumM = decimal.Parse(row["TOT_MUM_M"].ToString3());
this.planInfomation1.Value.TotWeightM = decimal.Parse(row["TOT_WEIGHT_M"].ToString3());
this.planInfomation1.UpdateData();
}
private string[] arr = null;
private void FrmStuffSurfaceResult_Load(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
//EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]);
EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]);
EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]);
EntityHelper.ShowGridCaption(ultraGrid3.DisplayLayout.Bands[0]);
arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"B", this.ob);
getPlineCode();
}
///
/// 获取产线
///
private void getPlineCode()
{
PlineCode = ClsLoad.GetPCode(UserInfo.GetDepartment(), ob);
}
private void ultraGrid2_ClickCellButton(object sender, CellEventArgs e)
{
this.ultraGrid2.UpdateData();
UltraGridRow uRow1 = this.ultraGrid1.ActiveRow;
UltraGridRow uRow = this.ultraGrid2.ActiveRow;
ArrayList list = new ArrayList();
list.Add(uRow.Cells["Furnaceno"].Text);
list.Add(uRow.Cells["Sequenceno"].Text);
list.Add(uRow.Cells["StoveNo"].Text);
list.Add(uRow.Cells["JudgeStoveNoSeq"].Text);
DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryPlanStaus", new object[] { list }, ob);
if (int.Parse(dt.Rows[0][0].ToString()) >= 20)
{
MessageUtil.ShowTips("表检已结炉,不允许进行离线、剔废操作!");
return;
}
string matNo = uRow.Cells["MatNo"].Text;
DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.doQueryRackStaus", new object[] { list,matNo }, ob);
string staus = ds.Rows[0][0].ToString();
int count = 0;
StlLgProgrrssEntity qcmLgProcessTity = (StlLgProgrrssEntity)uRow.ListObject;
//qcmLgProcessTity.PlineCode = PlineCode;
qcmLgProcessTity.ColUser = UserInfo.GetUserName();
qcmLgProcessTity.ColShift = UserInfo.GetUserOrder();
qcmLgProcessTity.ColGroup = UserInfo.GetUserGroup();
qcmLgProcessTity.Standardremak = uRow1.Cells["OrderNo"].Text.Trim();
qcmLgProcessTity.ScrapReason = uRow.Cells["ScrapReason"].Text;
string qcmProcessTity = JSONFormat.Format(qcmLgProcessTity);
if (e.Cell.Column.Key == "Scrap")
{
if (staus != "0")
{
MessageUtil.ShowTips("此坯已不是合格坯,不能进行剔除!");
return;
}
else
{
if (uRow.Cells["ScrapReason"].Text == "")
{
MessageUtil.ShowTips("请选择剔除原因!");
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "updateRackStaus";
ccp.ServerParams = new object[] { qcmProcessTity, "2", UserInfo.GetUserName(), uRow1.Cells["EfPlineCode"].Text,uRow1.Cells["EfPlineName"].Text };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("剔除成功!"))
{
doQueryRack(list);//查询管坯队列
}
}
//count = ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.updateRackStaus", new object[] { matNo, "2", uRow.Cells["ScrapReason"].Text, uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNoSeq"].Text, uRow.Cells["Furnaceno"].Text, uRow.Cells["Sequenceno"].Text }, ob);
//doQueryRack(list);//查询管坯队列
}
}
else if (e.Cell.Column.Key == "ScrapBack")
{
if (staus != "2")
{
MessageUtil.ShowTips("此坯不是废品坯,不能进行剔除回退!");
return;
}
else
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "updateRackStaus";
ccp.ServerParams = new object[] { qcmProcessTity, "0", UserInfo.GetUserName(), uRow1.Cells["EfPlineCode"].Text, uRow1.Cells["EfPlineName"].Text };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("剔除成功!"))
{
doQueryRack(list);//查询管坯队列
}
}
//count = ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult.updateRackStaus", new object[] { matNo, "0", "", uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNoSeq"].Text, uRow.Cells["Furnaceno"].Text, uRow.Cells["Sequenceno"].Text }, ob);
//doQueryRack(list);//查询管坯队列
}
}
else if (e.Cell.Column.Key == "Alarm")
{
if (staus != "0")
{
MessageUtil.ShowTips("此坯已不是合格坯,不能进行离线操作!");
return;
}
else
{
if (uRow.Cells["ScrapReason"].Text == "")
{
MessageUtil.ShowTips("请选择离线品中的废品原因!");
return;
}
if (uRow.Cells["ScrapReasonNum"].Text == "")
{
MessageUtil.ShowTips("请选择离线品中的废的单倍坯支数!");
return;
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "insertOffine";
ccp.ServerParams = new object[] { qcmProcessTity,UserInfo.GetUserName() };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("离线成功!"))
{
doQueryRack(list);//查询管坯队列
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
}
else if (e.Cell.Column.Key == "AlarmBack")
{
if (staus != "1")
{
MessageUtil.ShowTips("此坯不是待处理坯,不能进行离线回退!");
return;
}
else
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "insertOffineBack";
ccp.ServerParams = new object[] { qcmProcessTity };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("离线回退成功!"))
{
doQueryRack(list);//查询管坯队列
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
}
}
private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
{
this.ultraGrid2.UpdateData();
UltraGridRow uRow = this.ultraGrid2.ActiveRow;
if (uRow == null)
{
return;
}
if (!StringUtil.IsInt(uRow.Cells["ScrapLen"].Text.Trim().ToString3()))
{
MessageUtil.ShowTips("废品长度请输入正整数!");
return;
}
if (uRow.Cells["ScrapReason"].Text.Trim().Equals(""))
{
MessageUtil.ShowTips("请选择废品原因!");
return;
}
if(!uRow.Cells["Status"].Text.Trim().Equals("合格"))
{
MessageUtil.ShowTips("不是合格坯不允许记录废品长度!");
return;
}
ArrayList list = new ArrayList();
list.Add(uRow.Cells["Furnaceno"].Text);
list.Add(uRow.Cells["Sequenceno"].Text);
list.Add(uRow.Cells["StoveNo"].Text);
list.Add(uRow.Cells["JudgeStoveNoSeq"].Text);
StlLgProgrrssEntity stlLgProgss = (StlLgProgrrssEntity)uRow.ListObject;
string stlProgssEntity = JSONFormat.Format(stlLgProgss);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmStuffSurfaceResult";
ccp.MethodName = "saveScrapLen";
ccp.ServerParams = new object[] { stlProgssEntity };
ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
if (ccp.ReturnInfo.Equals("保存成功!"))
{
doQueryRack(list);//查询管坯队列
}
else
{
MessageUtil.ShowTips(ccp.ReturnInfo);
}
}
}
private void txtFurnace_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyValue == 13)
{
QuerySinglePlan();
}
}
private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
{
Infragistics.Win.ValueList valueList = new Infragistics.Win.ValueList();
if (e.Row.Cells["FixNum"].Text.ToString() != "")
{
int ScrapDBNum = int.Parse(e.Row.Cells["FixNum"].Text.ToString3()) -1;
valueList.ValueListItems.Add("", "");
for (int i = 0; i < ScrapDBNum; i++)
{
valueList.ValueListItems.Add((i + 1).ToString(), (i + 1).ToString());
}
}
else
{
valueList.ValueListItems.Add("0", "0");
}
e.Row.Cells["ScrapReasonNum"].ValueList = valueList;
}
}
}