using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Format;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
using Core.StlMes.Client.PlnSaleOrd.OrderManage.entity;
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;
namespace Core.StlMes.Client.PlnSaleOrd.管坯优化
{
public partial class FrmChangeGrade : FrmBase
{
private string Bom = "";//原BOM
private string GradeCode = "";//原钢种代码
private string GradeName = "";//原钢种
private string SpecCode = "";//原规格代码
private string SpecName = "";//原规格
private string OrdLnDlyPk = "";//交货行PK
private string ProPlanId = "";//订单编号
private string GxPlanNo = "";//排产序号
private string PlineCodeD = "";//轧管产线
private ArrayList PlineCodeEList = null;//镦拔扩产线
private ArrayList PlineCodeFList = null;//热处理产线
private ArrayList PlineCodeGList = null;//加工产线
private string MscPline = "";//原制程索引号
private string Month = "";//轧制月份
private string PassCode = "";//孔型代码
private string PassName = "";//孔型
private string DimaterManderl = "";//芯棒直径
private string AimDimater = "";
private string AimHeight = "";
private string specCodeR = "";//轧管规格代码
private string specNameR = "";//轧管规格
private string indexSeq = "";
public bool Flag = false;
private string[] groupCic = null;
private string cicGp = "";
private string gradeCodeAll = "";
private string diameter = "";
private string outsBilletfl = "";
private int num = 0;
public FrmChangeGrade()
{
InitializeComponent();
}
public FrmChangeGrade(string _outsBilletfl, string proPlanId, string gxPlanNo, OpeBase ob, string[] _groupCic, string _cicGp, string _gradeCodeAll, string _diameter, int _num)
{
InitializeComponent();
outsBilletfl = _outsBilletfl;
num = _num;
this.ProPlanId = proPlanId;
this.GxPlanNo = gxPlanNo;
this.ob = ob;
groupCic = _groupCic;
cicGp = _cicGp;
gradeCodeAll = _gradeCodeAll;
diameter = _diameter;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
}
private void FrmChangeGrade_Load(object sender, EventArgs e)
{
BaseHelper.setOtherColumnReadOnly(entityGridBom, new string[] { "CHC" });
BaseHelper.setOtherColumnReadOnly(ultraGridGrade, new string[] { "CHC" });
InitData();
}
private void InitData()
{
GetZgPlanInfo(ProPlanId, GxPlanNo);
//GetPlanOrderInfo(OrdLnDlyPk, ProPlanId);
txtSpec.Value = SpecName;
txtGrade.Value = GradeName;
txtDimater.Value = DimaterManderl;
txtPass.Value = PassName;
GetBomByOrdLnDlyPk();
GetGradeCic(GradeCode,outsBilletfl);
}
///
/// 查询轧管订单信息
///
///
///
public void GetZgPlanInfo(string proPlanId, string gxPlanNo)
{
List listSource = EntityHelper.GetData
("com.steering.pss.plnsaleord.orderManage.FrmBomConfirm.getZgPlanInfo",
new object[] { proPlanId, gxPlanNo }, this.ob);
if (listSource == null || listSource.Count() > 0)
{
Core.StlMes.Client.PlnSaleOrd.工序排产.entity.PlnOrderZgSOEntity entity = listSource[0];
this.PlineCodeD = entity.PlineCode;
this.SpecName = entity.DiameterGp.ToString();
this.Month = entity.ProMonth;
this.PassName = entity.PassName;
this.PassCode = entity.PassCode;
this.DimaterManderl = entity.DiameterMandrel.ToString();
this.AimDimater = entity.OutdiameterZg.ToString();
this.AimHeight = entity.WallthickZg.ToString();
this.GradeCode = entity.Gradecode;
this.GradeName = entity.Gradename;
this.OrdLnDlyPk = entity.OrdLnDlyPk;
MscPline = entity.IndexSeq;
Bom = entity.Bom;
specNameR = double.Parse(entity.OutdiameterZg.ToString()).ToString("f2") + "x" + double.Parse(entity.WallthickZg.ToString()).ToString("f2");
}
}
///
/// 查询轧管工序合同
///
///
///
//public void GetPlanOrderInfo(string ordLnDlyPk, string proPlanId)
//{
// DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.orderManage.FrmBomConfirm.getPlanOrderInfo", new object[] { ordLnDlyPk, proPlanId }, this.ob);
// if (dt != null && dt.Rows.Count > 0)
// {
// MscPline = dt.Rows[0]["INDEX_SEQ"].ToString();
// //Bom = dt.Rows[0]["Bom"].ToString();
// }
// else { MscPline = "";
// //Bom = "";
// }
//}
///
/// 查询BOM
///
///
public void GetBomByOrdLnDlyPk()
{
List listSource = EntityHelper.GetData
("com.steering.pss.plnsaleord.GpOptimize.FrmChangeGrade.getBomByOrdLnDlyPk",
new object[] { ProPlanId, GxPlanNo, gradeCodeAll, diameter, specNameR, MscPline }, this.ob);
slmOrdDesignBomEntityBindingSource.DataSource = listSource;
if (listSource != null && listSource.Count > 0)
{
foreach (UltraGridRow ugr in entityGridBom.Rows)
{
//specCodeR = ugr.Cells["SpecCodeR"].Text.ToString();
//specNameR = ugr.Cells["SpecNameR"].Text.ToString();
string bom = ugr.Cells["Bom"].Value.ToString();
string gradeName = ugr.Cells["GRADENAME"].Value.ToString();
string plineMsc = ugr.Cells["MscPline"].Value.ToString();
if (bom.Equals(Bom) && gradeName.Equals(GradeName) && plineMsc.Equals(MscPline))
{
ugr.Appearance.BackColor = Color.GreenYellow;
ugr.Activate();
return;
}
}
}
}
///
/// 钢种索引码
///
private void GetGradeCic(string gradCode, string outsBilletfl)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.GpOptimize.FrmChangeGrade.getQueryGrade",
new object[] { groupCic, outsBilletfl }, ob);
DataRow[] dr = dt.Select("GRADECODE LIKE '" + gradCode + "'", "");
if (dr == null || dr.Length == 0)
{
DataTable dt1 = new DataTable();
GridHelper.CopyDataToDatatable(dt1, this.dataTable1, true);
return;
}
DataTable tmp = dr[0].Table.Clone(); // 复制DataRow的表结构
foreach (DataRow row in dr)
{
tmp.ImportRow(row); // 将DataRow添加到DataTable中
}
GridHelper.CopyDataToDatatable(tmp, this.dataTable1, true);
foreach (UltraGridRow ugr in ultraGridGrade.Rows)
{
string stdIdx = ugr.Cells["CIC"].Value.ToString();
if (stdIdx.Equals(cicGp))
{
ugr.Appearance.BackColor = Color.GreenYellow;
ugr.Activate();
return;
}
}
}
private void entityGridBom_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow ugr = entityGridBom.ActiveRow;
if (ugr == null)
{
DataTable dt = new DataTable();
GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
}
else
{
BaseHelper.SetRowChecked(entityGridBom);
SlmOrdDesignBomEntity entity = (SlmOrdDesignBomEntity)ugr.ListObject;
GetGradeCic(entity.Gradecode,outsBilletfl);
}
}
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case "ChangeGrade": //修改钢种及钢种索引码
ChangeZgPlan();
break;
case "Close": // ButtonTool
this.Close();
break;
}
}
private string gradeNmaeCic = "";
public string GradeNmaeCic
{
get { return gradeNmaeCic; }
set { gradeNmaeCic = value; }
}
///
/// 修改钢种
///
private void ChangeZgPlan()
{
entityGridBom.UpdateData();
string cic = "";
string casTyte = "";
//BOM
ArrayList bomList = BaseHelper.GetRows(entityGridBom, "CHC", "True");
if (bomList == null || bomList.Count > 1) { MessageUtil.ShowTips("请选择钢种!"); return; }
SlmOrdDesignBomEntity bomEntity = (SlmOrdDesignBomEntity)bomList[0];
if (!bomEntity.MscPline.Equals(MscPline))
{
MessageUtil.ShowTips("制程发生改变,请重新选择BOM(如需变更制程,请重新下发)!"); return;
}
ultraGridGrade.UpdateData();
UltraGridRow row = ultraGridGrade.ActiveRow;
if (row != null)
{
int count = 0;
foreach (UltraGridRow rows in ultraGridGrade.Rows)
{
if (Convert.ToBoolean(rows.Cells["CHC"].Text) == true)
{
count++;
cic = rows.Cells["CIC"].Text.ToString();
if (rows.Cells["ALLOW_BUY"].Text.ToString().Equals("自炼"))
{
casTyte = "0";
}
else
{
casTyte = "1";
}
if (outsBilletfl.Equals("0") && casTyte.Equals("1"))
{
MessageUtil.ShowTips("请选择自炼钢种索引码!"); return;
}
else if (outsBilletfl.Equals("1") && casTyte.Equals("0"))
{
MessageUtil.ShowTips("请选择外购钢种索引码!"); return;
}
}
}
if (count == 0)
{
MessageUtil.ShowTips("请选择钢种索引码!"); return;
}
}
else
{
MessageUtil.ShowTips("无索引码!"); return;
}
if (num > 0)
{
//if (MessageUtil.ShowYesNoAndQuestion("存在LJ,装炉,出库支吨,是否需要拆分行?") == DialogResult.Yes)
//{
// MessageUtil.ShowTips("请联系轧管!");
// return;
//}
if (MessageUtil.ShowYesNoAndQuestion("存在LJ支吨,是否需要拆分行?") == DialogResult.Yes)
{
MessageUtil.ShowTips("请联系轧管!");
return;
}
}
if (MessageUtil.ShowYesNoAndQuestion("是否修改钢种?") == DialogResult.No)
{
return;
}
string[] param = BaseHelper.SetData("com.steering.pss.plnsaleord.GpOptimize.FrmChangeGrade.changeZgPlan", new object[] { bomEntity.Bom, ProPlanId,
GxPlanNo,cic,casTyte}, ob);
if (param == null) { MessageUtil.ShowTips("服务端处理失败!"); }
else
{
//MessageUtil.ShowWarning(param[1], entityGridBom);
MessageUtil.ShowTips(param[1]);
if ((bool.Parse(param[0]))) { Flag = true; InitData(); }
GradeNmaeCic = cic + bomEntity.Gradename;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
}
private void ultraGridGrade_AfterRowActivate(object sender, EventArgs e)
{
UltraGridRow ugr = ultraGridGrade.ActiveRow;
if (ugr == null)
{
return;
}
BaseHelper.SetRowChecked(ultraGridGrade);
}
}
}