| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Judge.Commons;
- using Core.StlMes.Client.Judge.Forms;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Judge.Controls
- {
- public sealed partial class QcmJudgeLockCtrl : UserControl
- {
- private readonly Dal _d;
- private readonly string _userId;
- public QcmJudgeLockCtrl(Control container, OpeBase ob, string userId)
- {
- InitializeComponent();
- _d = new Dal(ob);
- _userId = userId;
- container.Controls.Add(this);
- Dock = DockStyle.Fill;
- var lockFlagList = new ValueList();
- lockFlagList.ValueListItems.Add("0", "未锁定");
- lockFlagList.ValueListItems.Add("1", "已锁定");
- ultraGrid1.DisplayLayout.Bands[0].Columns["lockFlag"].ValueList = lockFlagList;
- }
- private string _judgeStoveNo = "";
- private string _orderMngNo = "";
- public void Query(string judgeStoveNo, string orderMngNo)
- {
- try
- {
- Cursor = Cursors.WaitCursor;
- _judgeStoveNo = judgeStoveNo;
- _orderMngNo = orderMngNo;
- var ccp = _d.Set("com.steering.pss.judge.Bll.BllQcmJudgeLock.query", judgeStoveNo,
- orderMngNo);
- if (ccp.ReturnInfo.ToString2() != "")
- {
- MessageUtil.ShowError(ccp.ReturnInfo.ToString2());
- return;
- }
- var dt = JsonHelper.toTable(ccp.ReturnObject.ToString2());
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- foreach (var row in ultraGrid1.Rows)
- {
- row.Cells["lgLock"].Value = false;
- row.Cells["zgLock"].Value = false;
- row.Cells["dbkLock"].Value = false;
- row.Cells["rclLock"].Value = false;
- row.Cells["jgxLock"].Value = false;
- row.Cells["jgLock"].Value = false;
- row.Cells["zcLock"].Value = false;
- //在途工序之前的工序不能选择
- if (row.GetValue("processCode") == "D")
- {
- row.Cells["lgLock"].Value = DBNull.Value;
- row.Cells["lgLock"].Activation = Activation.ActivateOnly;
- }
- else if (row.GetValue("processCode") == "E")
- {
- row.Cells["lgLock"].Value = DBNull.Value;
- row.Cells["lgLock"].Activation = Activation.ActivateOnly;
- row.Cells["zgLock"].Value = DBNull.Value;
- row.Cells["zgLock"].Activation = Activation.ActivateOnly;
- }
- else if (row.GetValue("processCode") == "F")
- {
- row.Cells["lgLock"].Value = DBNull.Value;
- row.Cells["lgLock"].Activation = Activation.ActivateOnly;
- row.Cells["zgLock"].Value = DBNull.Value;
- row.Cells["zgLock"].Activation = Activation.ActivateOnly;
- row.Cells["dbkLock"].Value = DBNull.Value;
- row.Cells["dbkLock"].Activation = Activation.ActivateOnly;
- }
- else if (row.GetValue("processCode") == "G")
- {
- row.Cells["lgLock"].Value = DBNull.Value;
- row.Cells["lgLock"].Activation = Activation.ActivateOnly;
- row.Cells["zgLock"].Value = DBNull.Value;
- row.Cells["zgLock"].Activation = Activation.ActivateOnly;
- row.Cells["dbkLock"].Value = DBNull.Value;
- row.Cells["dbkLock"].Activation = Activation.ActivateOnly;
- row.Cells["rclLock"].Value = DBNull.Value;
- row.Cells["rclLock"].Activation = Activation.ActivateOnly;
- }
- else if (row.GetValue("processCode") == "H")
- {
- row.Cells["lgLock"].Value = DBNull.Value;
- row.Cells["lgLock"].Activation = Activation.ActivateOnly;
- row.Cells["zgLock"].Value = DBNull.Value;
- row.Cells["zgLock"].Activation = Activation.ActivateOnly;
- row.Cells["dbkLock"].Value = DBNull.Value;
- row.Cells["dbkLock"].Activation = Activation.ActivateOnly;
- row.Cells["rclLock"].Value = DBNull.Value;
- row.Cells["rclLock"].Activation = Activation.ActivateOnly;
- row.Cells["jgxLock"].Value = DBNull.Value;
- row.Cells["jgxLock"].Activation = Activation.ActivateOnly;
- }
- else if (row.GetValue("processCode") == "ZC")
- {
- row.Cells["lgLock"].Value = DBNull.Value;
- row.Cells["lgLock"].Activation = Activation.ActivateOnly;
- row.Cells["zgLock"].Value = DBNull.Value;
- row.Cells["zgLock"].Activation = Activation.ActivateOnly;
- row.Cells["dbkLock"].Value = DBNull.Value;
- row.Cells["dbkLock"].Activation = Activation.ActivateOnly;
- row.Cells["rclLock"].Value = DBNull.Value;
- row.Cells["rclLock"].Activation = Activation.ActivateOnly;
- row.Cells["jgxLock"].Value = DBNull.Value;
- row.Cells["jgxLock"].Activation = Activation.ActivateOnly;
- row.Cells["jgLock"].Value = DBNull.Value;
- row.Cells["jgLock"].Activation = Activation.ActivateOnly;
- }
- if (row.Cells["lockProcessCode"].Value.ToString() == "A")
- row.Cells["lgLock"].Value = true;
- else if (row.Cells["lockProcessCode"].Value.ToString() == "D")
- row.Cells["zgLock"].Value = true;
- else if (row.Cells["lockProcessCode"].Value.ToString() == "E")
- row.Cells["dbkLock"].Value = true;
- else if (row.Cells["lockProcessCode"].Value.ToString() == "F")
- row.Cells["rclLock"].Value = true;
- else if (row.Cells["lockProcessCode"].Value.ToString() == "G")
- row.Cells["jgxLock"].Value = true;
- else if (row.Cells["lockProcessCode"].Value.ToString() == "H")
- row.Cells["jgLock"].Value = true;
- else if (row.Cells["lockProcessCode"].Value.ToString() == "ZC") row.Cells["zcLock"].Value = true;
- row.Update();
- }
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- }
- finally
- {
- Cursor = Cursors.Default;
- }
- }
- public void Lock()
- {
- var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("chk") == "True");
- var ultraGridRows = chkRows.ToList();
- if (!ultraGridRows.Any())
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- var popup = new PopupSubmit("锁定原因", true, "请输入锁定原因");
- string lockReason;
- if (popup.ShowDialog() == DialogResult.Yes)
- {
- lockReason = popup.TxtAudit.Text.Trim();
- if (lockReason == "")
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- }
- else
- {
- return;
- }
- var jsons = new List<string>();
- var lockId = ultraGrid1.ActiveRow.GetValue("lockId");
- foreach (var row in ultraGridRows)
- {
- SetLockProcess(row);
- jsons.Add(JsonHelper.ToJson(row));
- }
- var ccp = _d.Set("com.steering.pss.judge.Bll.BllQcmJudgeLock.lock", jsons, lockReason, _userId);
- if (ccp.ReturnInfo.ToString2() != "")
- {
- MessageUtil.ShowWarning(ccp.ReturnInfo.ToString2());
- }
- else
- {
- MessageUtil.ShowTips("操作成功!");
- Relocate(lockId);
- }
- }
- private void Relocate(string lockId)
- {
- Query(_judgeStoveNo, _orderMngNo);
- var row = ultraGrid1.Rows.FirstOrDefault(a => a.GetValue("lockId") == lockId);
- if (row != null) row.Activate();
- }
- private void SetLockProcess(UltraGridRow row)
- {
- if (row.GetValue("lgLock") != "True" && row.GetValue("zgLock") != "True" &&
- row.GetValue("dbkLock") != "True"
- && row.GetValue("rclLock") != "True" && row.GetValue("jgxLock") != "True" &&
- row.GetValue("jgLock") != "True"
- && row.GetValue("zcLock") != "True")
- row.SetValue("lockProcessCode", row.GetValue("processCode"));
- else if (row.GetValue("lgLock") == "True")
- row.SetValue("lockProcessCode", "A");
- else if (row.GetValue("zgLock") == "True")
- row.SetValue("lockProcessCode", "D");
- else if (row.GetValue("dbkLock") == "True")
- row.SetValue("lockProcessCode", "E");
- else if (row.GetValue("rclLock") == "True")
- row.SetValue("lockProcessCode", "F");
- else if (row.GetValue("jgxLock") == "True")
- row.SetValue("lockProcessCode", "G");
- else if (row.GetValue("jgLock") == "True")
- row.SetValue("lockProcessCode", "H");
- else if (row.GetValue("zcLock") == "True") row.SetValue("lockProcessCode", "ZC");
- }
- public void Unlock()
- {
- var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("chk") == "True");
- var ultraGridRows = chkRows.ToList();
- if (!ultraGridRows.Any())
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认解锁?") == DialogResult.No) return;
- var jsons = new List<string>();
- var lockId = ultraGrid1.ActiveRow.GetValue("lockId");
- foreach (var row in ultraGridRows) jsons.Add(JsonHelper.ToJson(row));
- var ccp = _d.Set("com.steering.pss.judge.Bll.BllQcmJudgeLock.unlock", jsons, _userId);
- if (ccp.ReturnInfo.ToString2() != "")
- {
- MessageUtil.ShowWarning(ccp.ReturnInfo.ToString2());
- }
- else
- {
- MessageUtil.ShowTips("操作成功!");
- Relocate(lockId);
- }
- }
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- e.Cell.Row.Update();
- //string[] locks = new string[] { "lgLock", "zgLock", "dbkLock", "rclLock", "jgxLock", "jgLock", "zcLock" };
- //foreach (string strLock in locks)
- //{
- // if (strLock == e.Cell.Column.Key)
- // {
- // e.Cell.Row.Cells[strLock].Value = true;
- // }
- // else
- // {
- // e.Cell.Row.Cells[strLock].Value = false;
- // }
- //}
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- }
- private void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e)
- {
- if (e.Cell.Column.Key.EndsWith("Lock") && e.Cell.Value.ToString2() == "True")
- {
- string[] locks = { "lgLock", "zgLock", "dbkLock", "rclLock", "jgxLock", "jgLock", "zcLock" };
- foreach (var strLock in locks)
- {
- if (strLock == e.Cell.Column.Key || e.Cell.Row.Cells[strLock].Value.ToString2() != "True") continue;
- e.Cell.Row.Cells[strLock].Value = false;
- }
- }
- e.Cell.Row.Update();
- }
- private void ultraGrid1_AfterHeaderCheckStateChanged(object sender,
- AfterHeaderCheckStateChangedEventArgs e)
- {
- _headerCheck = false;
- }
- private void ultraGrid1_BeforeCellUpdate(object sender, BeforeCellUpdateEventArgs e)
- {
- if (_headerCheck && e.Cell.Value == DBNull.Value) e.Cancel = true;
- }
- private bool _headerCheck;
- private void ultraGrid1_BeforeHeaderCheckStateChanged(object sender, BeforeHeaderCheckStateChangedEventArgs e)
- {
- _headerCheck = true;
- }
- }
- }
|