| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- 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<CraftOrdDesignAuditEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- }
- private string[] _dataPurviewIds;
- private string _userId;
- private CraftOrdDesignEntity _queryCondition;
- /// <summary>
- /// 查询工艺评审主表
- /// </summary>
- /// <param name="craftOrdDesign"></param>
- 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);
- }
- }
- /// <summary>
- /// 科室审核审核
- /// </summary>
- public void Audit(string reason)
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
- 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]);
- }
- /// <summary>
- /// 相关科室审核
- /// </summary>
- public void Audit1(string reason)
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
- 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]);
- }
- /// <summary>
- /// 部门审批
- /// </summary>
- public void Approval(string reason)
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
- foreach (UltraGridRow row in rows)
- {
- CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity<CraftOrdDesignEntity>(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]);
- }
- /// <summary>
- /// 批准
- /// </summary>
- public void Approval1(string reason)
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
- foreach (UltraGridRow row in rows)
- {
- CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity<CraftOrdDesignEntity>(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]);
- }
- /// <summary>
- /// 作废
- /// </summary>
- public void AuditOrApprovalFail(string type, string reason)
- {
- ultraGrid1.UpdateData();
- IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where("CHK = 'True'");
- if (rows.Count() == 0)
- {
- MessageUtil.ShowWarning("请选择一行记录!");
- return;
- }
- List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
- 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]);
- }
- /// <summary>
- /// 获取冶金规范的使用次数
- /// </summary>
- /// <param name="ordLnPk"></param>
- /// <returns></returns>
- 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<UltraGridRow> 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();
- }
- }
- }
|