| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Core.StlMes.Client.SaleOrder.BLL;
- using CoreFS.CA06;
- using Core.Mes.Client.Comm.Tool;
- using Core.Mes.Client.Comm.Server;
- using Core.StlMes.Client.Qcm;
- using CoreFS.SA06;
- namespace Core.StlMes.Client.SaleOrder.Control
- {
- public partial class CraftAutoPeopleCtrl : UserControl
- {
- private CraftAutoPeopleBLL _craftAutoPeople;
- private OpeBase _ob;
- public CraftAutoPeopleCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- _ob = ob;
- _craftAutoPeople = new CraftAutoPeopleBLL(ob);
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- }
- private string _customInfo = "";
- public void Query(string customInfo)
- {
- _customInfo = customInfo;
- craftAutoPeopleEntityBindingSource.DataSource = _craftAutoPeople.Query(customInfo);
- }
- public void QueryPopup(string ordLnPk)
- {
- craftAutoPeopleEntityBindingSource.DataSource = _craftAutoPeople.QueryPopup(ordLnPk);
- entityGrid1.DisplayLayout.Bands[0].Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No;
- DataRow dr = _craftAutoPeople.GetCraftOrdUnit(ordLnPk);
- if (dr != null)
- {
- var row = entityGrid1.Rows.Where(a => a.GetValue("AuditCode") == dr["AUDIT_CODE"].ToString() && a.GetValue("AuditCode1") == dr["AUDIT_CODE1"].ToString()
- && a.GetValue("ApproveCode") == dr["APPROVE_CODE"].ToString() && a.GetValue("ApproveCode1") == dr["APPROVE_CODE1"].ToString()).FirstOrDefault();
- if (row != null)
- {
- row.Cells["Chk"].Value = true;
- row.Update();
- }
- }
- }
- public bool Submit(string ordLnPk, string userId, string userName)
- {
- var row = entityGrid1.Rows.Where(a=>a.GetValue("Chk") == "True").FirstOrDefault();
- if (row == null)
- {
- MessageUtil.ShowWarning("请选择一条记录!");
- return false;
- }
- _craftAutoPeople.Submit(ordLnPk, row.GetValue("AuditCode"), row.GetValue("AuditCode1"),
- row.GetValue("ApproveCode"), row.GetValue("ApproveCode1"), userId, userName);
- MessageUtil.ShowTips("确认成功!");
- return true;
- }
- public void Save()
- {
- entityGrid1.UpdateData();
- var rows = entityGrid1.Rows.Where(a=>a.GetValue("Chk") == "True");
- List<CraftAutoPeopleEntity> parms = new List<CraftAutoPeopleEntity>();
- if (rows.Where(a => a.GetValue("AutoFlag") == "True").GroupBy(a => a.GetValue("unitCode")).Where(a => a.Count() > 1).Count() > 0)
- {
- MessageUtil.ShowWarning("保存的数据中,自动审核存在重复的数据!");
- return;
- }
- int count = rows.Where(a => a.GetValue("AutoFlag") == "False").GroupBy(a => new { unitCode = a.GetValue("unitCode"), auditCode = a.GetValue("auditCode"),
- auditCode1 = a.GetValue("auditCode1"), approveCode = a.GetValue("approveCode"), approveCode1 = a.GetValue("approveCode1") })
- .Where(a=>a.Count() > 1).Count();
- if (count > 0)
- {
- MessageUtil.ShowWarning("保存的数据中,人工审核存在重复的数据!");
- return;
- }
- foreach (var row in rows)
- {
- CraftAutoPeopleEntity parm = EntityHelper.CopyEntity<CraftAutoPeopleEntity>(row.ListObject);
- bool isExistUnit;
- if (parm.AutoFlag == true)
- {
- isExistUnit = _craftAutoPeople.IsExistUnit(parm.UnitCode, (parm.Pk == null ? "0" : parm.Pk.ToString()));
- }
- else
- {
- isExistUnit = _craftAutoPeople.IsExistUnit2(parm.UnitCode, parm.AuditCode, parm.AuditCode1,
- parm.ApproveCode, parm.ApproveCode1, (parm.Pk == null ? "0" : parm.Pk.ToString()));
- }
-
- if (parm.UnitCode == "")
- {
- MessageUtil.ShowWarning("请选择管理科室!");
- row.SetCellActive("UnitDesc");
- return;
- }
- if (parm.AuditCode == "")
- {
- MessageUtil.ShowWarning("请选择科室审核人!");
- row.SetCellActive("AuditDesc");
- return;
- }
- if (parm.AuditCode1 == "")
- {
- MessageUtil.ShowWarning("请选择相关科室审核人!");
- row.SetCellActive("AuditDesc1");
- return;
- }
- if (parm.ApproveCode == "")
- {
- MessageUtil.ShowWarning("请选择审批人!");
- row.SetCellActive("ApproveDesc");
- return;
- }
- if (isExistUnit)
- {
- MessageUtil.ShowWarning("存在相同的数据!");
- row.SetCellActive("UnitDesc");
- return;
- }
- parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
- parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parms.Add(parm);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
- {
- return;
- }
- _craftAutoPeople.Save(parms);
- MessageUtil.ShowTips("保存成功!");
- Query(_customInfo);
- }
- public void Delete()
- {
- entityGrid1.UpdateData();
- var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
- List<CraftAutoPeopleEntity> parms = new List<CraftAutoPeopleEntity>();
- foreach (var row in rows)
- {
- CraftAutoPeopleEntity parm = EntityHelper.CopyEntity<CraftAutoPeopleEntity>(row.ListObject);
- parms.Add(parm);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.No)
- {
- return;
- }
- _craftAutoPeople.Delete(parms);
- MessageUtil.ShowTips("删除成功!");
- Query(_customInfo);
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- var row = entityGrid1.ActiveRow;
- DataTable dt;
- BaseInfoPopup popup;
- switch (entityGrid1.ActiveCell.Column.Key)
- {
- case "UnitDesc":
- dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetUnit",
- new object[]{}, _ob);
- dt.Columns["DEPARTNAME1"].Caption = "管理部门";
- dt.Columns["DEPARTNAME"].Caption = "管理科室";
- popup = new BaseInfoPopup(dt, "DEPARTNAME", "DEPARTID");
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("UnitCode", popup.ChoicedRow.GetValue("DEPARTID"));
- row.SetValue("UnitDesc", popup.ChoicedRow.GetValue("DEPARTNAME"));
- }
- break;
- case "AuditDesc":
- dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
- new object[]{}, _ob);
- dt.Columns["USERNAME"].Caption = "评审人";
- dt.Columns["DEPARTNAME1"].Caption = "管理部门";
- dt.Columns["DEPARTNAME"].Caption = "管理科室";
- popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("AuditCode", popup.ChoicedRow.GetValue("USERID"));
- row.SetValue("AuditDesc", popup.ChoicedRow.GetValue("USERNAME"));
- }
- break;
- case "AuditDesc1":
- dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
- new object[] { }, _ob);
- dt.Columns["USERNAME"].Caption = "评审人";
- dt.Columns["DEPARTNAME1"].Caption = "管理部门";
- dt.Columns["DEPARTNAME"].Caption = "管理科室";
- popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("AuditCode1", popup.ChoicedRow.GetValue("USERID"));
- row.SetValue("AuditDesc1", popup.ChoicedRow.GetValue("USERNAME"));
- }
- break;
- case "ApproveDesc":
- dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
- new object[] { }, _ob);
- dt.Columns["USERNAME"].Caption = "评审人";
- dt.Columns["DEPARTNAME1"].Caption = "管理部门";
- dt.Columns["DEPARTNAME"].Caption = "管理科室";
- popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("ApproveCode", popup.ChoicedRow.GetValue("USERID"));
- row.SetValue("ApproveDesc", popup.ChoicedRow.GetValue("USERNAME"));
- }
- break;
- case "ApproveDesc1":
- dt = ServerHelper.GetData("com.steering.pss.sale.order.DAL.CraftAutoPeopleDAL.GetAudit",
- new object[] { }, _ob);
- dt.Rows.InsertAt(dt.NewRow(), 0);
- dt.Columns["USERNAME"].Caption = "评审人";
- dt.Columns["DEPARTNAME1"].Caption = "管理部门";
- dt.Columns["DEPARTNAME"].Caption = "管理科室";
- popup = new BaseInfoPopup(dt, "USERNAME", "DEPARTID", "USERID");
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("ApproveCode1", popup.ChoicedRow.GetValue("USERID"));
- row.SetValue("ApproveDesc1", popup.ChoicedRow.GetValue("USERNAME"));
- }
- break;
- }
- row.Update();
- }
- private void entityGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- e.Cell.Row.Update();
- }
- private void entityGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
- {
- if (_customInfo == "Auto")
- {
- e.Row.Cells["autoFlag"].Value = true;
- }
- else
- {
- e.Row.Cells["autoFlag"].Value = false;
- }
- }
- }
- }
|