| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- 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 ComBaseInfoCtrl : UserControl
- {
- private ComBaseInfoBLL _baseInfoBLL;
- private string _sortCode = "";
- private string _baseName = "";
- private string _validflag = "";
- public ComBaseInfoCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- _baseInfoBLL = new ComBaseInfoBLL(ob);
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- EntityHelper.ShowGridCaption<ComBaseInfoEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- }
- public void Query(string sortCode, string baseName, string validflag)
- {
- _sortCode = sortCode;
- _baseName = baseName;
- _validflag = validflag;
- List<ComBaseInfoEntity> baseInfoEntitys = _baseInfoBLL.Query(sortCode, baseName, validflag);
- comBaseInfoEntityBindingSource.DataSource = baseInfoEntitys;
- foreach (var row in ultraGrid1.Rows)
- {
- GridEdite(row);
- }
- }
- public void Relocat(string baseCode)
- {
- Query(_sortCode, _baseName, _validflag);
- var row = ultraGrid1.Rows.Where(a => a.GetValue("BASECODE") == baseCode).FirstOrDefault();
- if (row != null)
- {
- row.Activate();
- }
- }
- public void Save()
- {
- var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
- if (chkRows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择记录!");
- return;
- }
- var groupRows = chkRows.GroupBy(a => a.GetValue("BASENAME"));
- if (chkRows.Count() > groupRows.Count())
- {
- MessageUtil.ShowWarning("在保存的数据中,存在重复项!");
- return;
- }
- List<ComBaseInfoEntity> baseInfoEntitys = new List<ComBaseInfoEntity>();
- string baseCode = "";
- foreach (var chkRow in chkRows)
- {
- ComBaseInfoEntity parm = EntityHelper.CopyEntity<ComBaseInfoEntity>(chkRow.ListObject);
- if (parm.Validflag == "")
- {
- parm.Basecode = "N";
- }
- if (_baseInfoBLL.QueryBaseNameCnt(_sortCode, parm.Basename, parm.Basecode) > 0)
- {
- MessageUtil.ShowWarning("系统已经存在探伤级别——" + parm.Basename + "!");
- return;
- }
- parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
- parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- baseInfoEntitys.Add(parm);
- baseCode = parm.Basecode;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
- {
- return;
- }
- _baseInfoBLL.Save(baseInfoEntitys);
- MessageUtil.ShowTips("保存成功!");
- Relocat(baseCode);
- }
- public void UpdateValidflag(string validflag)
- {
- var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
- if (chkRows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择记录!");
- return;
- }
- List<ComBaseInfoEntity> baseInfoEntitys = new List<ComBaseInfoEntity>();
- string baseCode = "";
- foreach (var chkRow in chkRows)
- {
- ComBaseInfoEntity parm = EntityHelper.CopyEntity<ComBaseInfoEntity>(chkRow.ListObject);
- parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- baseInfoEntitys.Add(parm);
- baseCode = parm.Basecode;
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认" + (validflag == "0" ? "作废" : "恢复") + "?") == DialogResult.No)
- {
- return;
- }
- _baseInfoBLL.UpdateValidflag(baseInfoEntitys, validflag);
- MessageUtil.ShowTips((validflag == "0" ? "作废" : "恢复") + "成功!");
- Relocat(baseCode);
- }
- 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)
- {
- ultraGrid1.UpdateData();
- GridEdite(e.Cell.Row);
- }
- private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["SortCode"].Value = _sortCode;
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.GetValue("VALIDFLAG") == "无效")
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- }
- }
- }
|