| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- 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;
- /// <summary>
- /// 是否是弹窗
- /// </summary>
- 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<string> listNoEdit = new List<string>();
- listNoEdit.Add("创建人");
- listNoEdit.Add("创建时间");
- listNoEdit.Add("修改人");
- listNoEdit.Add("修改时间");
- listNoEdit.Add("作废人");
- listNoEdit.Add("作废时间");
- listNoEdit.Add("有效状态");
- listNoEdit.Add("产品规格代码");
- List<string> listDrop = new List<string>();
- 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<string> listNoEdit = new List<string>();
- listNoEdit.Add("创建人");
- listNoEdit.Add("创建时间");
- listNoEdit.Add("修改人");
- listNoEdit.Add("修改时间");
- listNoEdit.Add("作废人");
- listNoEdit.Add("作废时间");
- listNoEdit.Add("有效标志");
- listNoEdit.Add("订货规格代码");
- ControlGridSelectEdit(e, listNoEdit, new List<string>(), "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";
- }
- }
- }
|