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 Infragistics.Win.UltraWinGrid; using CoreFS.SA06; using Core.Mes.Client.Comm.Server; namespace Core.StlMes.Client.SaleOrder.Control { public partial class CraftOrdDesignAuditCtrl : UserControl { private CraftOrdDesignBLL _craftOrdDesignBLL; private OpeBase ob = null; public CraftOrdDesignAuditCtrl(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); this.ob = ob; _craftOrdDesignBLL = new CraftOrdDesignBLL(ob); this.Dock = DockStyle.Fill; container.Controls.Add(this); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); } private string[] _dataPurviewIds; private string _userId; private CraftOrdDesignEntity _queryCondition; /// /// 查询工艺评审主表 /// /// public void Query(CraftOrdDesignEntity craftOrdDesign, string[] DataPurviewIds, string userId) { _dataPurviewIds = DataPurviewIds; _userId = userId; _queryCondition = craftOrdDesign; craftOrdDesignEntityBindingSource.DataSource = _craftOrdDesignBLL.QueryAudit(craftOrdDesign, DataPurviewIds, userId); foreach (UltraGridRow row in ultraGrid1.Rows) { GridEdite(row); } } /// /// 科室审核审核 /// public void Audit(string reason) { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一行记录!"); return; } List craftOrdDesignList = new List(); foreach (UltraGridRow row in rows) { CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); if (craftOrdDesignSts.Validflag != "3") { MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); Relocate(craftOrdDesign); return; } craftOrdDesignList.Add(new CraftOrdDesignEntity() { LockFlag = "1", Validflag = "6", AuditName = CoreUserInfo.UserInfo.GetUserName(), OrdLnPk = craftOrdDesign.OrdLnPk, CraftSeq = craftOrdDesign.CraftSeq, Reason = reason }); } _craftOrdDesignBLL.Audit(craftOrdDesignList); MessageUtil.ShowTips("审核成功!"); Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); } /// /// 相关科室审核 /// public void Audit1(string reason) { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一行记录!"); return; } List craftOrdDesignList = new List(); foreach (UltraGridRow row in rows) { CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); if (craftOrdDesignSts.Validflag != "6") { MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); Relocate(craftOrdDesign); return; } craftOrdDesignList.Add(new CraftOrdDesignEntity() { LockFlag = "1", Validflag = "4", AuditName1 = CoreUserInfo.UserInfo.GetUserName(), OrdLnPk = craftOrdDesign.OrdLnPk, CraftSeq = craftOrdDesign.CraftSeq, Reason = reason }); } _craftOrdDesignBLL.Audit1(craftOrdDesignList); MessageUtil.ShowTips("审核成功!"); Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); } /// /// 部门审批 /// public void Approval(string reason) { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一行记录!"); return; } List craftOrdDesignList = new List(); foreach (UltraGridRow row in rows) { CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity(row.ListObject); CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); if (craftOrdDesignSts.Validflag != "4") { MessageUtil.ShowWarning("只能审批待审批状态的工艺文件!"); Relocate(craftOrdDesign); return; } string validflag = craftOrdDesign.CraftSeq > 1 ? "8" : "1"; //只有技术中心科室的人需要批准操作,否则审批之后直接生效。 /*DataTable dtComMsc = GetComMscByOrdLnPk(craftOrdDesign.OrdLnPk, ob); if (dtComMsc.Rows[0]["DEPARTMENT_CODE"].ToString() == "002001007") { validflag = "7"; }*/ craftOrdDesign.LockFlag = "1"; craftOrdDesign.Validflag = validflag; craftOrdDesign.ApprovalName = CoreUserInfo.UserInfo.GetUserName(); craftOrdDesign.Reason = reason; craftOrdDesignList.Add(craftOrdDesign); } _craftOrdDesignBLL.Approval(craftOrdDesignList); MessageUtil.ShowTips("审批成功!"); Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); } /// /// 批准 /// public void Approval1(string reason) { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一行记录!"); return; } List craftOrdDesignList = new List(); foreach (UltraGridRow row in rows) { CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity(row.ListObject); CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); if (craftOrdDesignSts.Validflag != "7") { MessageUtil.ShowWarning("只能批准待批准状态的工艺文件!"); Relocate(craftOrdDesign); return; } craftOrdDesign.LockFlag = "1"; craftOrdDesign.Validflag = craftOrdDesign.CraftSeq > 1 ? "8" : "1"; craftOrdDesign.ApprovalName1 = CoreUserInfo.UserInfo.GetUserName(); craftOrdDesign.Reason = reason; craftOrdDesignList.Add(craftOrdDesign); } _craftOrdDesignBLL.UpdateApprove1Name(craftOrdDesignList); _craftOrdDesignBLL.Approval1(craftOrdDesignList); MessageUtil.ShowTips("批准成功!"); Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); } /// /// 作废 /// public void AuditOrApprovalFail(string type, string reason) { ultraGrid1.UpdateData(); IQueryable rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'"); if (rows.Count() == 0) { MessageUtil.ShowWarning("请选择一行记录!"); return; } List craftOrdDesignList = new List(); foreach (UltraGridRow row in rows) { CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject; CraftOrdDesignEntity craftOrdDesignSts = _craftOrdDesignBLL.QueryByPk(craftOrdDesign); if (type == "科室审核" && craftOrdDesignSts.Validflag != "3") { MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); Relocate(craftOrdDesign); return; } if (type == "相关科室审核" && craftOrdDesignSts.Validflag != "6") { MessageUtil.ShowWarning("只能审核待审状态的工艺文件!"); Relocate(craftOrdDesign); return; } if (type == "审批" && craftOrdDesignSts.Validflag != "4") { MessageUtil.ShowWarning("只能审批待审批状态的工艺文件!"); Relocate(craftOrdDesign); return; } if (type == "批准" && craftOrdDesignSts.Validflag != "7") { MessageUtil.ShowWarning("只能批准待批准状态的工艺文件!"); Relocate(craftOrdDesign); return; } craftOrdDesignList.Add(new CraftOrdDesignEntity() { ApprovalName = CoreUserInfo.UserInfo.GetUserName(), AuditName = CoreUserInfo.UserInfo.GetUserName(), OrdLnPk = craftOrdDesign.OrdLnPk, CraftSeq = craftOrdDesign.CraftSeq, Reason = reason, LockFlag = "1", Validflag = "5" }); } if (type == "科室审核") { _craftOrdDesignBLL.Audit(craftOrdDesignList); } else if (type == "相关科室审核") { _craftOrdDesignBLL.Audit1(craftOrdDesignList); } else if (type == "审批") { _craftOrdDesignBLL.Approval(craftOrdDesignList); } else if (type == "批准") { _craftOrdDesignBLL.Approval1(craftOrdDesignList); } MessageUtil.ShowTips("操作成功!"); Relocate(craftOrdDesignList[craftOrdDesignList.Count - 1]); } /// /// 获取冶金规范的使用次数 /// /// /// public static DataTable GetComMscByOrdLnPk(string ordLnPk, OpeBase ob) { return ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreOrderReviewTechnology.getComMscByOrdLnPk", new object[] { ordLnPk }, ob); } private void Relocate(CraftOrdDesignEntity craftOrdDesign) { Query(_queryCondition, _dataPurviewIds, _userId); if (craftOrdDesign == null) return; IQueryable queryableRows = ultraGrid1.Rows.AsQueryable().Where( a => a.GetValue("OrdLnPk") == craftOrdDesign.OrdLnPk && a.GetValue("CraftSeq") == craftOrdDesign.CraftSeq.ToString2()); if (queryableRows.Count() > 0) { queryableRows.First().Activate(); } } 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; } } } ultraGrid1.UpdateData(); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { e.Cell.Row.Update(); } PopupTextBox popupTextBox; private void ultraTextEditor2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { string key = ultraGrid1.ActiveCell.Column.Key; if (key == "CraftChangeMemo" || key == "OrderSpecialDesc" || key == "OrderAddDesc" || key == "OrderAddDescA") { popupTextBox = new PopupTextBox(ultraGrid1.ActiveCell.Value.ToString()); popupTextBox.TxtInfo.ReadOnly = true; popupTextBox.UltraPanel1.Visible = false; popupTextBox.Show(); } } private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { string filePathOld = ultraGrid1.ActiveCell.Row.GetValue("CraftPathOld"); dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld); down.DeleteButton.Visible = false; down.ShowDialog(); } } }