| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- using Core.Mes.Client.Comm.Format;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Qcm.BLL;
- using Core.StlMes.Client.Qcm.model;
- using CoreFS.CA06;
- using CoreFS.SA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm.Control
- {
- public partial class ComBaseStdRTestCtrl : UserControl
- {
- private ComBaseStdRTestBLL _comBaseStdRTestBLL;
- private OpeBase _ob;
- //查询条件
- private string _phyNameMin = "";
- private string _validflag = "";
- public ComBaseStdRTestCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- _ob = ob;
- _comBaseStdRTestBLL = new ComBaseStdRTestBLL(ob);
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- EntityHelper.ShowGridCaption<ComBaseStdRTestEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- }
- public void Query(string phyNameMin, string validflag)
- {
- _validflag = validflag;
- _phyNameMin = phyNameMin;
- comBaseStdRTestEntityBindingSource.DataSource = _comBaseStdRTestBLL.Query(phyNameMin, validflag);
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- GridEdite(row);
- }
- }
- public void Relocate(string phyCodeMin)
- {
- Query(_phyNameMin, _validflag);
- var row = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("PhyCodeMin") == phyCodeMin).FirstOrDefault();
- if (row != null)
- {
- row.Activate();
- }
- }
- public void Save()
- {
- var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一条记录!");
- return;
- }
- List<ComBaseStdRTestEntity> parms = new List<ComBaseStdRTestEntity>();
- foreach (var row in rows)
- {
- ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
- if (stdRTestEntity.PhyCodeMin == "")
- {
- MessageUtil.ShowWarning("请选择试样组!");
- row.SetCellActive("PhyNameMin");
- return;
- }
- if (stdRTestEntity.StdCodeTest == "")
- {
- MessageUtil.ShowWarning("请选择试验标准!");
- row.SetCellActive("StdNameTest");
- return;
- }
- if (_comBaseStdRTestBLL.GetRepateCnt(stdRTestEntity.StdCodeTest,
- stdRTestEntity.PhyCodeMin, stdRTestEntity.Pk) > 0)
- {
- MessageUtil.ShowWarning("系统已存在 试样组:" + stdRTestEntity.PhyNameMin
- + " + 试验标准:" + stdRTestEntity.StdNameTest + "的组合!");
- return;
- }
- if (stdRTestEntity.LevelTest == null)
- {
- stdRTestEntity.LevelTest = 1;
- }
- stdRTestEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
- stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parms.Add(stdRTestEntity);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
- {
- return;
- }
- _comBaseStdRTestBLL.Save(parms);
- MessageUtil.ShowTips("保存成功!");
- Relocate(parms[0].PhyCodeMin);
- }
- public List<string> GetSaveParms()
- {
- ultraGrid1.UpdateData();
- var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
- List<string> parms = new List<string>();
- foreach (var row in rows)
- {
- ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
- if (stdRTestEntity.StdNameTest == "")
- {
- MessageUtil.ShowWarning("请选择试验标准!");
- row.SetCellActive("StdNameTest");
- return null;
- }
- else if (stdRTestEntity.PhyNameMin == "")
- {
- MessageUtil.ShowWarning("请选择试样组!");
- row.SetCellActive("PhyNameMin");
- return null;
- }
- else if (stdRTestEntity.LevelTest == null)
- {
- MessageUtil.ShowWarning("请输入优先级!");
- row.SetCellActive("LevelTest");
- return null;
- }
- stdRTestEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
- stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parms.Add(JSONFormat.Format(stdRTestEntity));
- }
- return parms;
- }
- public void UpdateValidflag(string validflag)
- {
- var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择记录!");
- return;
- }
- List<ComBaseStdRTestEntity> parms = new List<ComBaseStdRTestEntity>();
- foreach (var row in rows)
- {
- ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
- stdRTestEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parms.Add(stdRTestEntity);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认" +
- (validflag == "0" ? "作废" : "恢复") + "选择的记录?") == DialogResult.No)
- {
- return;
- }
- _comBaseStdRTestBLL.UpdateValidflag(parms, validflag);
- MessageUtil.ShowTips((validflag == "0" ? "作废" : "恢复") + "成功!");
- Relocate(parms[0].PhyCodeMin);
- }
- public List<string> GetUpdateValidflagParms()
- {
- ultraGrid1.UpdateData();
- var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
- List<string> parms = new List<string>();
- foreach (var row in rows)
- {
- ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
- stdRTestEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parms.Add(JSONFormat.Format(stdRTestEntity));
- }
- return parms;
- }
- private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
- {
- if (e.Row.GetValue("Validflag") == "无效")
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- }
- private void ultraGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
- {
- ultraGrid1.UpdateData();
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- if (ultraGrid1.ActiveCell.Column.Key == "StdNameTest")
- {
- //DataTable dt = _comBaseStdRTestBLL.GetComBaseStdS();
- //dt.Columns["STD_NAME"].Caption = "试验标准";
- //BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE");
- //baseInfoPopup.LabelTextBox1.Caption = "试验标准";
- //var row = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
- // a => a.GetValue("STD_CODE") == ultraGrid1.ActiveRow.GetValue("StdCodeTest")).FirstOrDefault();
- //if (row != null)
- //{
- // row.Activate();
- //}
- //if (baseInfoPopup.ShowDialog() == DialogResult.OK)
- //{
- // ultraGrid1.ActiveRow.SetValue("StdCodeTest", baseInfoPopup.ChoicedRow.GetValue("STD_CODE"));
- // ultraGrid1.ActiveRow.SetValue("StdNameTest", baseInfoPopup.ChoicedRow.GetValue("STD_NAME"));
- //}
- string stdCodes = ultraGrid1.ActiveRow.GetValue("StdCodeTest");
- ComBaseStdChoice baseStdChoice = new ComBaseStdChoice(new string[] { "S" }, stdCodes, _ob);
- if (baseStdChoice.ShowDialog() == DialogResult.OK)
- {
- ultraGrid1.ActiveRow.SetValue("StdCodeTest", baseStdChoice.ChoiceStdCodes);
- ultraGrid1.ActiveRow.SetValue("StdNameTest", baseStdChoice.ChoiceStdNames);
- }
- }
- else if (ultraGrid1.ActiveCell.Column.Key == "PhyNameMin")
- {
- DataTable dt = _comBaseStdRTestBLL.GetComBasePhyC();
- dt.Columns["PHY_TYPE"].Caption = "试样组";
- BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "PHY_TYPE", "PHY_CODE");
- baseInfoPopup.LabelTextBox1.Caption = "试样组";
- var row = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
- a => a.GetValue("PHY_CODE") == ultraGrid1.ActiveRow.GetValue("PhyCodeMin")).FirstOrDefault();
- if (row != null)
- {
- row.Activate();
- }
- if (baseInfoPopup.ShowDialog() == DialogResult.OK)
- {
- ultraGrid1.ActiveRow.SetValue("PhyCodeMin", baseInfoPopup.ChoicedRow.GetValue("PHY_CODE"));
- ultraGrid1.ActiveRow.SetValue("PhyNameMin", baseInfoPopup.ChoicedRow.GetValue("PHY_TYPE"));
- }
- }
- }
- private void GridEdite(UltraGridRow row)
- {
- if (row.GetValue("Chk") == "True")
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.Key == "Chk") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
- {
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- e.Cell.Row.Update();
- GridEdite(e.Cell.Row);
- }
- }
- }
|