| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Data;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class ComBaseSplineStdSizeFrm : FrmBase
- {
- public ComBaseSplineStdSizeFrm()
- {
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Query":
- Query();
- break;
- case "Save":
- Save();
- break;
- case "Delete":
- Delete();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- public void Query()
- {
- dataTable1.Clear();
- dataTable2.Clear();
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseSplineStdSize.querySplineStd", new string[] { }, ob);
- GridHelper.CopyDataToDatatable(dt, dataTable3, true);
- foreach (var row in ultraGrid3.Rows)
- {
- GridEdite(row);
- }
- }
- public void Save()
- {
- var stdRow = ultraGrid3.Rows.Where(a => a.GetValue("CHK") == "True").FirstOrDefault();
- var sizeRows = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True");
- var specRows = ultraGrid2.Rows.Where(a => a.GetValue("CHK") == "True");
- if (stdRow == null && sizeRows.Count() == 0 && specRows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一条记录!");
- return;
- }
- string[] stdParm = new string[3];
- string id = ultraGrid3.ActiveRow.GetValue("ID");
- if (stdRow != null)
- {
- stdParm = new string[] { stdRow.GetValue("spline_direction"), stdRow.GetValue("spline_std_code"), stdRow.GetValue("ID") };
- }
- ArrayList sizeList = new ArrayList();
- foreach (var row in sizeRows)
- {
- if (row.GetValue("ITEM_CODE_S") == "")
- {
- MessageUtil.ShowWarning("请选择试样尺寸");
- row.Cells["ITEM_CODE_S"].Activate();
- return;
- }
- if (row.GetValue("MIN_SIGN") != "" && row.GetValue("MIN_SIZE") == "")
- {
- MessageUtil.ShowWarning("请输入尺寸下限!");
- row.SetCellActive("MIN_SIZE");
- return;
- }
- else if (row.GetValue("MIN_SIGN") == "" && row.GetValue("MIN_SIZE") != "")
- {
- MessageUtil.ShowWarning("请选择尺寸下限符号!");
- row.SetCellActive("MIN_SIGN");
- return;
- }
- else if (row.GetValue("MAX_SIGN") != "" && row.GetValue("MAX_SIZE") == "")
- {
- MessageUtil.ShowWarning("请输入尺寸上限值!");
- row.SetCellActive("MAX_SIZE");
- return;
- }
- else if (row.GetValue("MAX_SIGN") == "" && row.GetValue("MAX_SIZE") != "")
- {
- MessageUtil.ShowWarning("请选择尺寸上限符号!");
- row.SetCellActive("MAX_SIGN");
- return;
- }
- else if (row.GetValue("MIN_SIGN") == "=" && row.GetValue("MAX_SIGN") != "")
- {
- MessageUtil.ShowWarning("尺寸下限符号为等号时,不能存在尺寸上限符号和尺寸上限值!");
- row.SetCellActive("MIN_SIGN");
- return;
- }
- else if (row.GetValue("MIN_SIZE") != "" && row.GetValue("MAX_SIZE") != ""
- && decimal.Parse(row.GetValue("MIN_SIZE")) >= decimal.Parse(row.GetValue("MAX_SIZE")))
- {
- MessageUtil.ShowWarning("尺寸下限值不能大于等于尺寸上限值!");
- row.SetCellActive("MIN_SIZE");
- return;
- }
- string[] parm = new string[] { row.GetValue("ITEM_CODE_S"), row.GetValue("MIN_SIZE"), row.GetValue("MAX_SIZE"),
- row.GetValue("RATE"), row.GetValue("MIN_SIGN"), row.GetValue("MAX_SIGN"), row.GetValue("ID"), row.GetValue("SEQ")};
- sizeList.Add(parm);
- }
- ArrayList specList = new ArrayList();
- foreach (var row in specRows)
- {
- if (row.GetValue("MIN_D_SIGN") != "" && row.GetValue("MIN_D") == "")
- {
- MessageUtil.ShowWarning("请输入外径下限值!");
- row.SetCellActive("MIN_D");
- return;
- }
- else if (row.GetValue("MIN_D_SIGN") == "" && row.GetValue("MIN_D") != "")
- {
- MessageUtil.ShowWarning("请选择外径下限符号!");
- row.SetCellActive("MIN_D_SIGN");
- return;
- }
- else if (row.GetValue("MAX_D_SIGN") != "" && row.GetValue("MAX_D") == "")
- {
- MessageUtil.ShowWarning("请输入外径上限值!");
- row.SetCellActive("MAX_D");
- return;
- }
- else if (row.GetValue("MAX_D_SIGN") == "" && row.GetValue("MAX_D") != "")
- {
- MessageUtil.ShowWarning("请选择外径上限符号!");
- row.SetCellActive("MAX_D_SIGN");
- return;
- }
- else if (row.GetValue("MIN_H_SIGN") != "" && row.GetValue("MIN_H") == "")
- {
- MessageUtil.ShowWarning("请输入壁厚下限值!");
- row.SetCellActive("MIN_H");
- return;
- }
- else if (row.GetValue("MIN_H_SIGN") == "" && row.GetValue("MIN_H") != "")
- {
- MessageUtil.ShowWarning("请选择壁厚下限符号!");
- row.SetCellActive("MIN_H_SIGN");
- return;
- }
- else if (row.GetValue("MAX_H_SIGN") != "" && row.GetValue("MAX_H") == "")
- {
- MessageUtil.ShowWarning("请输入壁厚上限值!");
- row.SetCellActive("MAX_H");
- return;
- }
- else if (row.GetValue("MAX_H_SIGN") == "" && row.GetValue("MAX_H") != "")
- {
- MessageUtil.ShowWarning("请选择壁厚上限符号!");
- row.SetCellActive("MAX_H_SIGN");
- return;
- }
- else if (row.GetValue("MIN_D_SIGN") == "=" && row.GetValue("MAX_D_SIGN") != "")
- {
- MessageUtil.ShowWarning("外径下限符号为等号时,不能存在外径上限符号和外径上限值!");
- row.SetCellActive("MAX_D_SIGN");
- return;
- }
- else if (row.GetValue("MIN_H_SIGN") == "=" && row.GetValue("MAX_H_SIGN") != "")
- {
- MessageUtil.ShowWarning("壁厚下限符号为等号时,不能存在壁厚上限符号和壁厚上限值!");
- row.SetCellActive("MAX_H_SIGN");
- return;
- }
- else if (row.GetValue("MIN_D") != "" && row.GetValue("MAX_D") != ""
- && decimal.Parse(row.GetValue("MIN_D")) >= decimal.Parse(row.GetValue("MAX_D")))
- {
- MessageUtil.ShowWarning("外径下限值不能大于等于外径上限值!");
- row.SetCellActive("MIN_D");
- return;
- }
- else if (row.GetValue("MIN_H") != "" && row.GetValue("MAX_H") != ""
- && decimal.Parse(row.GetValue("MIN_H")) >= decimal.Parse(row.GetValue("MAX_H")))
- {
- MessageUtil.ShowWarning("壁厚下限值不能大于等于壁厚上限值!");
- row.SetCellActive("MIN_H");
- return;
- }
- string[] parm = new string[] { row.GetValue("ITEM_CODE_S"), row.GetValue("MIN_D"),
- row.GetValue("MAX_D"), row.GetValue("MIN_H"), row.GetValue("MAX_H"), row.GetValue("MIN_D_SIGN"),
- row.GetValue("MAX_D_SIGN"), row.GetValue("MIN_H_SIGN"), row.GetValue("MAX_H_SIGN"), row.GetValue("ID"),
- row.GetValue("SEQ")};
- specList.Add(parm);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No)
- {
- return;
- }
- ServerHelper.SetData("com.steering.pss.qcm.ComBaseSplineStdSize.save", new object[] { stdParm, sizeList, specList }, ob);
- MessageUtil.ShowTips("保存成功!");
- Query();
- var actRow = ultraGrid3.Rows.Where(a => a.GetValue("ID") == id).FirstOrDefault();
- if (actRow != null)
- {
- actRow.Activate();
- }
- }
- private void Delete()
- {
- var stdRow = ultraGrid3.Rows.Where(a => a.GetValue("CHK") == "True").FirstOrDefault();
- var sizeRows = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True");
- var specRows = ultraGrid2.Rows.Where(a => a.GetValue("CHK") == "True");
- if (stdRow == null && sizeRows.Count() == 0 && specRows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一条记录!");
- return;
- }
- string stdId = "";
- if (stdRow != null)
- {
- stdId = stdRow.GetValue("ID");
- }
- ArrayList sizeList = new ArrayList();
- foreach (var row in sizeRows)
- {
- sizeList.Add(new string[] { row.GetValue("ID"), row.GetValue("SEQ") });
- }
- ArrayList specList = new ArrayList();
- foreach (var row in specRows)
- {
- specList.Add(new string[] { row.GetValue("ID"), row.GetValue("SEQ") });
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == System.Windows.Forms.DialogResult.No)
- {
- return;
- }
- ServerHelper.SetData("com.steering.pss.qcm.ComBaseSplineStdSize.delete", new object[] { stdId, sizeList, specList }, ob);
- MessageUtil.ShowTips("删除成功!");
- Query();
- }
- 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_CellChange(object sender, CellEventArgs e)
- {
- e.Cell.Row.Update();
- GridEdite(e.Cell.Row);
- }
- private void ComBaseSplineMinSizeFrm_Load(object sender, EventArgs e)
- {
- LoadItemData_sub("C", ultraComboEditor3);
- }
- private void LoadItemData_sub(string itemStyle, UltraComboEditor cmb)
- {
- ArrayList list = new ArrayList();
- list.Add(itemStyle);
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreMaterialItemMng.loadItem",
- new object[] { list }, ob);
- dt.DefaultView.RowFilter = "ITEM_CODE IN ('I0009', 'I0010', 'I0083', 'I0011', 'I0012', 'I0081', 'I0013', 'I0082', 'I0014')";
- dt.DefaultView.Sort = "ITEM_NAME";
- DataRow dr = dt.NewRow();
- dr["ITEM_CODE"] = "";
- dt.Rows.InsertAt(dr, 0);
- cmb.DataSource = dt.DefaultView.ToTable();
- cmb.DisplayMember = "ITEM_NAME";
- cmb.ValueMember = "ITEM_CODE";
- cmb.DropDownListWidth = -1;
- ClsBaseInfo.SetComboItemHeight(cmb);
- }
- private void QuerySplineSize(string id)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseSplineStdSize.querySplineSize",
- new object[] { id }, ob);
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- foreach (var row in ultraGrid1.Rows)
- {
- GridEdite(row);
- }
- }
- private void QuerySplineSpec(string id)
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseSplineStdSize.querySplineSpec",
- new object[] { id }, ob);
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- foreach (var row in ultraGrid2.Rows)
- {
- GridEdite(row);
- }
- }
- private void ultraGrid3_CellChange(object sender, CellEventArgs e)
- {
- e.Cell.Row.Update();
- if (e.Cell.Column.Key == "CHK")
- {
- UltraGridRow chkRow = e.Cell.Row;
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- if (row.Cells["CHK"].Value.ToString() == "True" && row != chkRow)
- {
- row.Cells["CHK"].Value = "False";
- row.Update();
- }
- }
- }
- GridEdite(e.Cell.Row);
- e.Cell.Row.Update();
- }
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["ID"].Value = ultraGrid3.GetActiveRowValue("ID");
- }
- private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["ID"].Value = ultraGrid3.GetActiveRowValue("ID");
- }
- private void ultraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
- {
- if (ultraGrid3.GetActiveRowValue("ID") == "")
- {
- e.Cancel = true;
- }
- }
- private void ultraGrid2_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
- {
- if (ultraGrid3.GetActiveRowValue("ID") == "")
- {
- e.Cancel = true;
- }
- }
- private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
- {
- string id = ultraGrid3.GetActiveRowValue("ID");
- QuerySplineSize(id);
- QuerySplineSpec(id);
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- this.Cursor = Cursors.WaitCursor;
- var actRow = ultraGrid3.ActiveRow;
- ComBaseStdChoice baseStdChoice = new ComBaseStdChoice(new string[] { "S" }, actRow.GetValue("SPLINE_STD_CODE"), ob);
- this.Cursor = Cursors.Default;
- if (baseStdChoice.ShowDialog() == DialogResult.OK)
- {
- actRow.SetValue("SPLINE_STD_CODE", baseStdChoice.ChoiceStdCodes);
- actRow.SetValue("SPLINE_STD_NAME", baseStdChoice.ChoiceStdNames);
- }
- }
- private void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- e.Cell.Row.Update();
- GridEdite(e.Cell.Row);
- }
- }
- }
|