using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Tool;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
using System;
using System.Collections.Generic;
namespace Core.StlMes.Client.Qcm
{
public partial class FrmSpecificationsBasicsNew2 : FrmBaseQcm
{
private string _strSelectedGrid = "1";
private string _parentSelectedFlag = "";
private string _childSelectedFlag = "";
private bool _isPopup = false;
///
/// 是否是弹窗
///
public bool IsPopup
{
get { return _isPopup; }
set { _isPopup = value; }
}
private string _mscStyle = "";
public string MscStyle
{
get { return _mscStyle; }
set { _mscStyle = value; }
}
public FrmSpecificationsBasicsNew2()
{
InitializeComponent();
ExceptionHelper.RegistException();
}
public void PopupLoad(OpeBase ob)
{
this.OnLoad(EventArgs.Empty);
this.ob = ob;
}
private void FrmSpecificationsBasicsNew2_Load(object sender, EventArgs e)
{
QcmBaseInfo.Fill_SpecType(cmbBindType, false);
_dtBaseQcm = new DtSpecificationsBasicsNew2(this);
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
base.ToolBar_Click(sender, ToolbarKey);
switch (ToolbarKey)
{
case "Export":
Export();
break;
}
}
protected override void BeginDoAction(ActionType actionType)
{
SetValueToCHK();
}
protected override void SuccessDoAction(ActionType actionType)
{
if (_parentSelectedFlag == "")
{
SetGridRowActiveWithKey(ultraGrid1, "SPEC_CODE", "CREATE_NAME", "CREATE_TIME");
}
else
{
SetGridRowActiveWithKey(ultraGrid1, "SPEC_CODE", _parentSelectedFlag);
}
if (_childSelectedFlag == "")
{
SetGridRowActiveWithKey(ultraGrid2, "ORDER_SPEC_CODE", "CREATE_NAME", "CREATE_TIME");
}
else
{
SetGridRowActiveWithKey(ultraGrid2, "ORDER_SPEC_CODE", _childSelectedFlag);
}
}
private void SetValueToCHK()
{
_parentSelectedFlag = "";
_childSelectedFlag = "";
foreach (UltraGridRow row in ultraGrid1.Rows)
{
if (row.Cells["CHK"].Value.ToString() == "True")
{
string specCode = row.Cells["SPEC_CODE"].Value.ToString();
if (specCode != "")
{
_parentSelectedFlag = specCode;
}
else
{
_parentSelectedFlag = "";
}
}
}
if (_parentSelectedFlag == "")
{
if (ultraGrid1.ActiveRow != null)
{
_parentSelectedFlag = ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value.ToString();
}
}
foreach (UltraGridRow row in ultraGrid2.Rows)
{
if (row.Cells["CHK"].Value.ToString() == "True")
{
string orderSpecCode = row.Cells["ORDER_SPEC_CODE"].Value.ToString();
if (orderSpecCode != "")
{
_childSelectedFlag = orderSpecCode;
}
else
{
_childSelectedFlag = "";
}
}
}
ultraGrid1.UpdateData();
ultraGrid2.UpdateData();
}
private void Export()
{
if (_strSelectedGrid == "2")
{
GridHelper.ulGridToExcel(ultraGrid2, "规格管理从表");
}
else
{
GridHelper.ulGridToExcel(ultraGrid1, "规格管理主表");
}
}
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
SetDeleteColor(e, "VALIDFLAG", "0");
BandComboToGrid1(e.Row);
ControlGrid1Edit(e);
}
public void BandComboToGrid1(UltraGridRow row)
{
row.Cells["MSC_STYLE"].EditorComponent = cmbBindType;
}
private void ultraGrid2_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
SetDeleteColor(e, "VALIDFLAG", "0");
ControlGrid2Edit(e);
}
private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
ultraGrid1.UpdateData();
SpecTypeChange(e);
ControlGridCheck(e);
ultraGrid1.UpdateData();
}
private void ControlGridCheck(CellEventArgs e)
{
if (e.Cell.Column.Key == "CHK" && _isPopup == false)
{
UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1,
new string[] { "CHK" }, new string[] { "True" });
foreach (UltraGridRow row in rows)
{
if (row.Cells["CHK"] != e.Cell)
{
row.Cells["CHK"].Value = false;
}
}
}
}
private void SpecTypeChange(CellEventArgs e)
{
if (e.Cell.Row.Cells["MSC_STYLE"].Value.ToString() == "A")
{
string spec_Name = "";
spec_Name += e.Cell.Row.Cells["DIMATER"].Value.ToString();
if (spec_Name == "" || e.Cell.Row.Cells["HEIGHT"].Value.ToString() == "")
{
spec_Name += e.Cell.Row.Cells["HEIGHT"].Value.ToString();
}
else
{
spec_Name += "x" + e.Cell.Row.Cells["HEIGHT"].Value.ToString();
}
e.Cell.Row.Cells["SPEC_NAME"].Value = spec_Name;
}
else if (e.Cell.Row.Cells["MSC_STYLE"].Value.ToString() == "B")
{
e.Cell.Row.Cells["SPEC_NAME"].Value = e.Cell.Row.Cells["DIMATER"].Value.ToString();
e.Cell.Row.Cells["HEIGHT"].Value = "";
}
else
{
e.Cell.Row.Cells["DIMATER"].Value = "";
e.Cell.Row.Cells["HEIGHT"].Value = "";
}
}
private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
ultraGrid2.UpdateData();
}
private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
{
e.Row.Cells["SPEC_NAME"].Value = ultraGrid1.ActiveRow.Cells["SPEC_NAME"].Value;
e.Row.Cells["SPEC_CODE"].Value = ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value;
e.Row.Cells["ORDER_SPEC_DESC"].Value = ultraGrid1.ActiveRow.Cells["SPEC_NAME"].Value;
}
private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
{
}
private void ControlGrid1Edit(InitializeRowEventArgs e)
{
List listNoEdit = new List();
listNoEdit.Add("创建人");
listNoEdit.Add("创建时间");
listNoEdit.Add("修改人");
listNoEdit.Add("修改时间");
listNoEdit.Add("作废人");
listNoEdit.Add("作废时间");
listNoEdit.Add("有效状态");
listNoEdit.Add("产品规格代码");
List listDrop = new List();
listDrop.Add("类型");
ControlGridSelectEdit(e, listNoEdit, listDrop, "CHK");
if (e.Row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
{
if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "A")
{
e.Row.Cells["DIMATER"].Activation = Activation.AllowEdit;
e.Row.Cells["HEIGHT"].Activation = Activation.AllowEdit;
e.Row.Cells["SPEC_NAME"].Activation = Activation.ActivateOnly;
}
else if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "B")
{
e.Row.Cells["DIMATER"].Activation = Activation.AllowEdit;
e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
e.Row.Cells["SPEC_NAME"].Activation = Activation.ActivateOnly;
}
else
{
e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
e.Row.Cells["SPEC_NAME"].Activation = Activation.AllowEdit;
}
}
else
{
if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "A")
{
e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
}
else if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "B")
{
e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
}
else
{
e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
}
}
}
private void ControlGrid2Edit(InitializeRowEventArgs e)
{
List listNoEdit = new List();
listNoEdit.Add("创建人");
listNoEdit.Add("创建时间");
listNoEdit.Add("修改人");
listNoEdit.Add("修改时间");
listNoEdit.Add("作废人");
listNoEdit.Add("作废时间");
listNoEdit.Add("有效标志");
listNoEdit.Add("订货规格代码");
ControlGridSelectEdit(e, listNoEdit, new List(), "CHK");
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
if (ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value.ToString() == "")
{
dataTable2.Clear();
return;
}
_dtBaseQcm.DoQuery("Child");
}
private void ultraGrid2_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
{
if (ultraGrid1.Rows.Count == 0 || ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value.ToString() == "")
{
e.Cancel = true;
}
}
private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
{
_strSelectedGrid = "1";
}
private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
{
_strSelectedGrid = "2";
}
}
}