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 com.steering.mes.zgmil.entity;
using Infragistics.Win.UltraWinGrid;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.ZGMil.NodeResultQuery;
using Core.StlMes.Client.ZGMil.Entity;
using System.Collections;
namespace Core.StlMes.Client.ZGMil.Result
{
public partial class FrmZPResult : FrmBase
{
#region 界面初始化
public FrmZPResult()
{
InitializeComponent();
ultraGridSimpleInfo.ClickCellButton += new CellEventHandler(ultraGridSimpleInfo_ClickCellButton);
}
///
/// 初始化控件
///
private void InitControl()
{
chkDate.Checked = false;
chkLotNo.Checked = false;
chkJudgeStoveNo.Checked = false;
}
#endregion
private void chkBox_CheckedChanged(object sender, EventArgs e)
{
if (chkDate.Checked == true)
{
dtStartTime.Enabled = true;
dtEndTime.Enabled = true;
}
else
{
dtStartTime.Enabled = false;
dtEndTime.Enabled = false;
}
if (chkLotNo.Checked == true)
{
this.txtLotNo.Enabled = true;
}
else
{
txtLotNo.Enabled = false;
}
if (chkJudgeStoveNo.Checked == true)
{
this.txtJudgeStoveNo.Enabled = true;
}
else
{
txtJudgeStoveNo.Enabled = false;
}
}
#region 方法
///
/// 刷新
///
private void Refresh(string JudgeStoveNo)
{
WaitZPQuery(JudgeStoveNo);
GetTxtNum();
}
///
/// 待组批查询
///
private void WaitZPQuery(string JudgeStoveNo)
{
DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmZPResult.waitZPQuery", new object[] { JudgeStoveNo }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
}
///
/// 得到选中待组批总支数
///
private void GetTxtNum()
{
int ToltalNum = 0;
int RowNum = 0;
if (ultraGrid2.Rows.Count > 0)
{
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
RowNum = Convert.ToInt32(ugr.Cells["COUNT"].Value.ToString());
ToltalNum += RowNum;
}
}
uneZPNum.Value = ToltalNum;
}
///
/// 判断主炉号 主性能批号是否选择
///
///
private bool IsSelected()
{
bool isSelected = false;
bool isHeatNo = false;
bool isSimple = false;
if (ultraGrid2.Rows.Count > 0)
{
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
if (ugr.Cells["HEATNO"].Value.ToString() == "true")
{
isHeatNo = true;
}
if (ugr.Cells["SIMPLE"].Value.ToString() == "true")
{
isSimple = true;
}
}
isSelected = isHeatNo && isSimple;
}
return isSelected;
}
///
/// 录入数据检验
///
private bool CheckEdit()
{
bool flag = true;
string JudgeStoveNo = "";
string SimpleNo = "";
string GroupNo = "";
//grid数据检验(修磨合废)
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
SimpleNo = ugr.Cells["SIMPLE_LOT_NO"].Value.ToString();
GroupNo = ugr.Cells["GROUP_NO"].Value.ToString();
if (string.IsNullOrEmpty(ugr.Cells["QUALIFIED_NUM"].Value.ToString()))
{
MessageBox.Show("炉号【" + JudgeStoveNo + "】性能批号【" + SimpleNo + "】分组号【" + GroupNo + "】修磨合格支数为空,请输入修磨合格支数!!!");
ultraGrid2.ActiveRow = ugr;
return flag = false;
}
if (string.IsNullOrEmpty(ugr.Cells["SCRAP_NUM"].Value.ToString()))
{
MessageBox.Show("炉号【" + JudgeStoveNo + "】性能批号【" + SimpleNo + "】分组号【" + GroupNo + "】修磨剔除支数为空,请输入修磨剔除支数!!!");
ultraGrid2.ActiveRow = ugr;
return flag = false;
}
if (Convert.ToInt32(ugr.Cells["COUNT"].Value.ToString()) != Convert.ToInt32(ugr.Cells["SCRAP_NUM"].Value.ToString()) + Convert.ToInt32(ugr.Cells["QUALIFIED_NUM"].Value.ToString()))
{
MessageBox.Show("炉号【" + JudgeStoveNo + "】性能批号【" + SimpleNo + "】分组号【" + GroupNo + "】下线支数不等于修磨合格支数与剔除支数之合,请修改!!!");
ultraGrid2.ActiveRow = ugr;
return flag = false;
}
}
//录入框数据检验
if (string.IsNullOrEmpty(txtJudgeStoveNoE.Text))
{
MessageBox.Show("组批炉号为空,请输入组批炉号!!!");
return flag = false;
}
if (string.IsNullOrEmpty(this.txtLotNoE.Text))
{
MessageBox.Show("组批生产批号为空,请输入组批生产批号!!!");
return flag = false;
}
if (string.IsNullOrEmpty(this.txtGradeE.Text))
{
MessageBox.Show("组批钢级为空,请输入组批钢级!!!");
return flag = false;
}
if (string.IsNullOrEmpty(this.txtSteelE.Text))
{
MessageBox.Show("组批钢种为空,请输入组批钢种!!!");
return flag = false;
}
if (string.IsNullOrEmpty(this.txtStandardE.Text))
{
MessageBox.Show("组批标准为空,请输入组批标准!!!");
return flag = false;
}
if (string.IsNullOrEmpty(uneLengthE.Value.ToString()))
{
MessageBox.Show("组批长度为空,请输入组批长度!!!");
return flag = false;
}
if (string.IsNullOrEmpty(uneLengthMin.Value.ToString()) || string.IsNullOrEmpty(uneLengthMax.Value.ToString()))
{
MessageBox.Show("组批长度范围为空,请输入组批长度范围!!!");
return flag = false;
}
if (string.IsNullOrEmpty(uneDiameter.Value.ToString()) || string.IsNullOrEmpty(uneDiameter.Value.ToString()))
{
MessageBox.Show("组批规格为空,请输入组批规格!!!");
return flag = false;
}
if (string.IsNullOrEmpty(uneHeightE.Value.ToString()))
{
MessageBox.Show("组批重量为空,请输入组批重量!!!");
return flag = false;
}
if (string.IsNullOrEmpty(cmbLevelE.Value.ToString()))
{
MessageBox.Show("组批等级为空,请输入组批等级!!!");
return flag = false;
}
return flag;
}
#endregion
#region 按钮事件
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
Query();
break;
case "DoZP":
btnZP();
break;
//case "Save":
// FeedRowSave();
// break;
//case "Node":
// FeedSawResultNode();
// break;
//case "Close":
// this.Dispose();
// this.Close();
// break;
}
}
///
/// 质检下线管查询
///
private void Query()
{
MilOfflineReslutEntity OffLineResultQuery = new MilOfflineReslutEntity();
string EndTime = "";
if (chkLotNo.Checked)
{
if (string.IsNullOrEmpty(txtLotNo.Text))
{
MessageBox.Show("请输入需查询的生产批号!!!");
return;
}
else
{
OffLineResultQuery.LotNo = this.txtLotNo.Text;
//OffLineResultQuery.JudgeStoveNo = this.txtJudgeStoveNo.Text;
}
}
else
{
OffLineResultQuery.LotNo = "";
//OffLineResultQuery.JudgeStoveNo = "";
}
if (this.chkJudgeStoveNo.Checked)
{
if (string.IsNullOrEmpty(txtJudgeStoveNo.Text))
{
MessageBox.Show("请输入需查询的炉号!!!");
return;
}
else
{
OffLineResultQuery.JudgeStoveNo = this.txtJudgeStoveNo.Text;
//OffLineResultQuery.LotNo = this.txtLotNo.Text;
}
}
else
{
OffLineResultQuery.JudgeStoveNo = "";
// OffLineResultQuery.LotNo = "";
}
if (chkDate.Checked == true)
{
if (dtStartTime.DateTime > dtEndTime.DateTime)
{
MessageBox.Show("开始时间不能大于结束时间。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else
{
OffLineResultQuery.OfflineTime = this.dtStartTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
EndTime = this.dtEndTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
}
}
else
{
OffLineResultQuery.OfflineTime = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss");
EndTime = DateTime.Now.AddMonths(+1).ToString("yyyy-MM-dd HH:mm:ss");
}
DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmZPResult.offLineResultQuery", new object[] { OffLineResultQuery, EndTime }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dtZPInfor, true);
if (dt.Rows.Count > 0)
{
}
else
{
MessageBox.Show("没有查询到的数据!!!");
return;
}
}
///
/// 点击下线炉信息行
///
///
///
private void ultraGridMatSeq_AfterRowActivate(object sender, EventArgs e)
{
if (ultraGridOffLineR.Rows.Count > 0)
{
UltraGridRow ugr = ultraGridOffLineR.ActiveRow;
string JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmZPResult.simpleResultQuery", new object[] { JudgeStoveNo }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dtSimple, true);
DataTable dt1 = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmZPResult.simpleDetailResultQuery", new object[] { JudgeStoveNo }, this.ob);
GridHelper.CopyDataToDatatable(ref dt1, ref dtSimpleDetail, true);
}
}
///
/// 分组按钮
///
///
///
void ultraGridSimpleInfo_ClickCellButton(object sender, CellEventArgs e)
{
string JudgeStoveNo = "";
string SimpleNo = "";
int GroupNo = 0;
int GroupNum = 0;
string User = UserInfo.GetUserName();
string Shift = UserInfo.GetUserOrder();
string Group = UserInfo.GetUserGroup();
if (e.Cell.Column.Key == "GROUPING")
{
if (!string.IsNullOrEmpty(e.Cell.Row.Cells["GROUPINGNUM"].Value.ToString()))
{
if (Convert.ToInt32(e.Cell.Row.Cells["GROUPINGNUM"].Value.ToString()) != 0)
{
GroupNo = int.Parse(e.Cell.Row.Cells["GROUP_NO"].Value.ToString());
GroupNum = int.Parse(e.Cell.Value.ToString());
SimpleNo = e.Cell.Row.Cells["SIMPLE_LOT_NO"].Value.ToString();
JudgeStoveNo = e.Cell.Row.Cells["JUDGE_STOVE_NO"].Value.ToString();
int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmZPResult.grouping", new object[] { JudgeStoveNo, SimpleNo, GroupNo,GroupNum, User, Shift, Group }, this.ob);
}
}
}
Refresh(JudgeStoveNo);
throw new NotImplementedException();
}
///
/// 双击性能批
///
///
///
private void ultraGridSimpleInfo_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
{
if (ultraGridSimpleInfo.Rows.Count > 0)
{
UltraGridRow ugr = ultraGridSimpleInfo.ActiveRow;
string JudgeStoveNo = "";
string Status = "";
string SimpleNo = "";
int GroupNum = 0;
//父行
if (ugr.HasChild())
{
ugr.ExpandAll();
}
else
{
if (ugr.Cells["STATUS"].Value.ToString() == "待组批" || ugr.Cells["STATUS"].Value.ToString() == "已组批")
{
return;
}
else
{
JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
SimpleNo = ugr.Cells["SIMPLE_LOT_NO"].Value.ToString();
GroupNum = int.Parse(ugr.Cells["GROUP_NO"].Value.ToString());
//修改性能批分组状态 (1-下线->2-待组批)
Status = "2";
int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmZPResult.updateSimpleGropuStatus", new object[] { JudgeStoveNo, SimpleNo, GroupNum, Status }, this.ob);
if (count > 0)
{
//int Num = Convert.ToInt32(ugr.Cells[""].Value.ToString());
//int ZPnum = 0;
//if (string.IsNullOrEmpty(txtZPNum.Text))
//{
// txtZPNum.Text = (ZPnum + Num).ToString();
//}
//else
//{
// txtZPNum.Text = (Convert.ToInt32(txtZPNum.Text) + Num).ToString();
//}
}
}
}
Refresh(JudgeStoveNo);
}
}
///
/// 待组批双击退回成下线
///
///
///
private void ultraGrid2_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
{
UltraGridRow ugr = ultraGrid2.ActiveRow;
string JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
string SimpleNo = ugr.Cells["SIMPLE_LOT_NO"].Value.ToString();
int GroupNum = int.Parse(ugr.Cells["GROUP_NO"].Value.ToString());
string Status = "1";
int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmZPResult.updateSimpleGropuStatus", new object[] { JudgeStoveNo, SimpleNo, GroupNum, Status }, this.ob);
if (count > 0)
{
Refresh(JudgeStoveNo);
}
}
///
/// 选中性能批主 炉号 主性能批号
///
///
///
private void ultraGrid2_CellChange(object sender, CellEventArgs e)
{
if (e.Cell.Column.Key == "HEATNO")
{
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
ugr.Cells["HEATNO"].Value = false;
}
e.Cell.Row.Cells["HEATNO"].Value = true;
}
else if (e.Cell.Column.Key == "SIMPLE")
{
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
ugr.Cells["SIMPLE"].Value = false;
}
e.Cell.Row.Cells["SIMPLE"].Value = true;
}
}
///
/// 组炉按钮
///
private void btnZP()
{
string JudgeStoveNo = ""; //炉号
string SimpleNo = ""; //性能批号
string MSipleJudgeStoveNo = ""; //主性能批主炉号
string Status = ""; //状态
string User = UserInfo.GetUserName();
string Shift = UserInfo.GetUserOrder();
string Group = UserInfo.GetUserGroup();
ArrayList GroupList = new ArrayList();
if (ultraGrid2.Rows.Count > 0)
{
MilOfflineGroupEntity GroupingEntity = new MilOfflineGroupEntity();
MilOfflineGroupResumeEntity GroupingRsumeEntity = new MilOfflineGroupResumeEntity();
ArrayList GroupEntityList = new ArrayList();
//判断主炉号 主性能批号是否选择
if (IsSelected())
{
if (CheckEdit()) //录入数据检验
{
Status = "4";
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
if (ugr.Cells["HEATNO"].Value.ToString() == "true")
{
JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
continue;
}
}
foreach (UltraGridRow ugr in ultraGrid2.Rows)
{
if (ugr.Cells["SIMPLE"].Value.ToString() == "true")
{
// Simple = ugr.Cells["SIMPLE_LOT_NO"].Value.ToString();
MSipleJudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
continue;
}
}
for (int i = 0; i < ultraGrid2.Rows.Count; i++)
{
//组炉履历实体类赋值
GroupingRsumeEntity.JudgeStoveNo = ultraGrid2.Rows[i].Cells["JUDGE_STOVE_NO"].Value.ToString();
GroupingRsumeEntity.SimpleLotNo = ultraGrid2.Rows[i].Cells["SIMPLE_LOT_NO"].Value.ToString();
GroupingRsumeEntity.GroupNo = ultraGrid2.Rows[i].Cells["GROUP_NO"].Value.ToString();
GroupingRsumeEntity.Count = ultraGrid2.Rows[i].Cells["COUNT"].Value.ToString();
GroupingRsumeEntity.QualifiedNum = ultraGrid2.Rows[i].Cells["QUALIFIED_NUM"].Value.ToString();
GroupingRsumeEntity.ScrapNum = ultraGrid2.Rows[i].Cells["SCRAP_NUM"].Value.ToString();
GroupingRsumeEntity.ColUser = User;
GroupingRsumeEntity.ColShift = Shift;
GroupingRsumeEntity.ColGroup = Group;
GroupingRsumeEntity.Status = Status;
GroupEntityList.Add(GroupingRsumeEntity);
}
//组炉实绩实体类赋值
GroupingEntity.ZpJudgeStoveNo = txtJudgeStoveNoE.Text;
GroupingEntity.ZpLotNo = txtLotNoE.Text;
GroupingEntity.ZpGrade = txtGradeE.Text;
GroupingEntity.ZpSteel = txtSteelE.Text;
GroupingEntity.ZpStandrad = txtStandardE.Text;
GroupingEntity.ZpLength = uneLengthE.Value.ToString();
//GroupingEntity.ZpLengthMax = uneLengthMax.Value.ToString();
// GroupingEntity.ZpLengthMin = uneLengthMin.Value.ToString();
GroupingEntity.ZpSize = this.uneDiameter.Value.ToString() + " x " + uneThick.Value.ToString();
GroupingEntity.ZpHeight = uneHeightE.Value.ToString();
GroupingEntity.ZpLevel = cmbLevelE.Value.ToString();
//GroupingEntity.Count = uneZPNum.Value.ToString();
//GroupingEntity.QualifiedNum = uneQualifiedNum.Value.ToString();
//GroupingEntity.ScrapNum = uneScrapNum.Value.ToString();
GroupingEntity.ZpMLh = JudgeStoveNo; //组批主炉号
GroupingEntity.ZpMPh = SimpleNo; //组批主性能批号
GroupingEntity.ZpSLh = MSipleJudgeStoveNo; //组批主性能批炉号
GroupingEntity.Remark = txtRemark.Text;
int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmZPResult.zp", new object[] { GroupEntityList, GroupingEntity }, this.ob);
}
else
{
return;
}
}
else
{
MessageBox.Show("请选择组批后主炉号和主性能批号");
return;
}
}
else
{
MessageBox.Show("请选择需要组批的性能批分组!!!");
}
}
#endregion
}
}