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 Infragistics.Win;
using com.steering.mes.zgmil.entity;
using System.Collections;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.ZGMil.Common;
namespace Core.StlMes.Client.ZGMil.Popup
{
public partial class FrmQASizeDetail : FrmBase
{
private string _JudgeStoveNo = "";
private string _LotNo = "";
private string _ResultNo = "";
private string _proPlanId = "";//轧管订单编号
private string _gxPlanNo = "";//工序排产序号
private string _PlineCode = "";
private string Shift = "";
private string Group = "";
private string User = "";
private DataTable _dtMatList = null;
private OpeBase _ob = null;
public FrmQASizeDetail(string JudgeStoveNo, string LotNo, string ResultNo, string proPlanId, string gxPlanNo, string PlineCode, OpeBase ob)
{
InitializeComponent();
_JudgeStoveNo = JudgeStoveNo;
_LotNo = LotNo;
_ResultNo = ResultNo;
_PlineCode = PlineCode;
_proPlanId = proPlanId;
_gxPlanNo = gxPlanNo;
_ob = ob;
ultraGrid3.ClickCellButton += new CellEventHandler(ultraGrid3_ClickCellButton); //添加缺陷项
InitCol();
if (!_PlineCode.Equals("C072"))
{
ultraGrid3.DisplayLayout.Bands[0].Columns["NON_ROUNDNESS"].Hidden = true;
ultraGrid3.DisplayLayout.Bands[0].Columns["UNEVEN_DEGREE"].Hidden = true;
}
}
///
/// 初始化控件
///
private void InitCol()
{
txtHeatNo.Text = BaseMethod.getJudgeStoveNo(_JudgeStoveNo);
txtLotNo.Text = _LotNo;
//查询几何尺寸抽检
SizeCheckQuery();
GetCheckMatList();
}
///
/// 查询抽检管记录
///
///
private void SizeCheckQuery()
{
DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.sizeCheckQuery", new object[] { BaseMethod.getJudgeStoveNo(_JudgeStoveNo), _ResultNo, _proPlanId, _gxPlanNo }, this._ob);
GridHelper.CopyDataToDatatable(ref dt, ref dtPipeSize, true);
Infragistics.Win.ValueList valueList = new Infragistics.Win.ValueList();
valueList.ValueListItems.Add("0", "管端");
valueList.ValueListItems.Add("1", "管体");
ultraGrid3.DisplayLayout.Bands[0].Columns["LOCATION"].ValueList = valueList;
}
///
/// 确认
///
///
///
private void btnOK_Click(object sender, EventArgs e)
{
this.ultraGrid3.UpdateData();
//1、删除现有尺寸抽查记录
//2、添加新的尺寸抽查记录
ArrayList ListCehckSize = new ArrayList();
for (int i = 0; i < ultraGrid3.Rows.Count; i++)
{
MilSizeCheckDeatilEntity CheckSizeEntity = new MilSizeCheckDeatilEntity();
CheckSizeEntity.ResultNo = _ResultNo;
CheckSizeEntity.SamplePipeSeq = ultraGrid3.Rows[i].Cells["SAMPLE_PIPE_SEQ"].Value.ToString();
if (i+1 > _dtMatList.Rows.Count)
{
CheckSizeEntity.SamplePipeNo = "";
}
else
{
CheckSizeEntity.SamplePipeNo = _dtMatList.Rows[i]["MAT_NO"].ToString();
}
CheckSizeEntity.JudgeStoveNo = _JudgeStoveNo;
CheckSizeEntity.D1 = ultraGrid3.Rows[i].Cells["D1"].Value.ToString();
CheckSizeEntity.D2 = ultraGrid3.Rows[i].Cells["D2"].Value.ToString();
CheckSizeEntity.S1 = ultraGrid3.Rows[i].Cells["S1"].Value.ToString();
CheckSizeEntity.S2 = ultraGrid3.Rows[i].Cells["S2"].Value.ToString();
CheckSizeEntity.S3 = ultraGrid3.Rows[i].Cells["S3"].Value.ToString();
CheckSizeEntity.S4 = ultraGrid3.Rows[i].Cells["S4"].Value.ToString();
CheckSizeEntity.NonRoundness = ultraGrid3.Rows[i].Cells["NON_ROUNDNESS"].Value.ToString();
CheckSizeEntity.UnevenDegree = ultraGrid3.Rows[i].Cells["UNEVEN_DEGREE"].Value.ToString();
string Location = ultraGrid3.Rows[i].Cells["LOCATION"].Value.ToString();
//if (Location == "管端")
//{
// Location = "0";
//}
//else
//{
// Location = "1";
//}
CheckSizeEntity.Location = Location;
CheckSizeEntity.ProPlanId = _proPlanId;
CheckSizeEntity.GxPlanNo = _gxPlanNo;
ListCehckSize.Add(CheckSizeEntity);
}
int count2 = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.insertMatSize", new object[] { ListCehckSize,_JudgeStoveNo,_ResultNo,_proPlanId,_gxPlanNo }, this._ob);
if (count2 > 0)
{
//CoreClientParam ccp = new CoreClientParam();
//ccp.ServerName = "com.steering.mes.zgmil.coup.SurfaceInspectionResult";
//ccp.MethodName = "updateActWgt";
//ccp.ServerParams = new object[] { _JudgeStoveNo.Substring(0,6) };
//ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
//if (ccp.ReturnCode != -1)
//{
// if (ccp.ReturnInfo.Equals("确认成功!"))
// {
// this.DialogResult = System.Windows.Forms.DialogResult.OK;
// }
// else
// {
// MessageUtil.ShowTips(ccp.ReturnInfo);
// }
//}
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
this.Close();
}
///
/// 查询抽检管管号队列信息
///
private void GetCheckMatList()
{
DataTable dtMatList = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.checkMatNoQuery", new object[] { _JudgeStoveNo, _ResultNo, _proPlanId, _gxPlanNo }, this._ob);
_dtMatList = dtMatList;
if (_dtMatList.Rows.Count == 0)
{
MessageUtil.ShowTips("无管号队列信息,请联系系统管理员!");
return;
}
}
///
/// 取消
///
///
///
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 新增尺寸行记录时
///
///
///
private void ultraGrid3_AfterRowInsert(object sender, RowEventArgs e)
{
//if (ultraGrid3.Rows.Count > _dtMatList.Rows.Count)
//{
// MessageBox.Show("超过可抽检管支数,不能新增!!!");
// return;
//}
e.Row.Cells["SAMPLE_PIPE_SEQ"].Value = dtPipeSize.Rows.Count +1;
}
//删除尺寸行记录
void ultraGrid3_ClickCellButton(object sender, CellEventArgs e)
{
if (e.Cell.Column.Key == "BTN_DELETE")
{
for (int i = 0; i < dtPipeSize.Rows.Count; i++)
{
ultraGrid3.Rows[i].Cells["SAMPLE_PIPE_SEQ"].Value = i + 1;
if (dtPipeSize.Rows[i]["SAMPLE_PIPE_SEQ"].ToString() == e.Cell.Row.Cells["SAMPLE_PIPE_SEQ"].Value.ToString())
{
dtPipeSize.Rows.RemoveAt(i);
break;
}
}
for (int i = 0; i < dtPipeSize.Rows.Count; i++)
{
ultraGrid3.Rows[i].Cells["SAMPLE_PIPE_SEQ"].Value = i + 1;
}
ultraGrid3.DataBind();
}
}
///
/// 复制整行记录 (可编辑列)
///
///
///
private void ultraGrid3_KeyDown(object sender, KeyEventArgs e)
{
ultraGrid3.DisplayLayout.Bands[0].Override.AllowMultiCellOperations = AllowMultiCellOperation.Copy | AllowMultiCellOperation.Paste;
if (e.Control && e.KeyCode == Keys.C)
{
ultraGrid3.PerformAction(UltraGridAction.Copy);
}
else if (e.Control && e.KeyCode == Keys.V)
{
ultraGrid3.PerformAction(UltraGridAction.Paste);
}
}
private void ultraGrid3_Error(object sender, ErrorEventArgs e)
{
e.Cancel = true;
}
}
}