| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- using Core.Mes.Client.Comm.Server;
- 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 delegate void ClearData();
- public partial class ComBasePurchaseAgreementCtrl : UserControl
- {
- private ComBasePurchaseAgreementBLL _purchaseAgreementBLL;
- private OpeBase _ob;
- public event ClearData ClearData;
- public ComBasePurchaseAgreementCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- _ob = ob;
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- _purchaseAgreementBLL = new ComBasePurchaseAgreementBLL(ob);
- EntityHelper.ShowGridCaption<ComBasePurchaseAgreementCtrlEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- }
- private string agreementDesc = "";
- private string validflag = "";
- public void Query(string agreementDesc, string validflag)
- {
- this.agreementDesc = agreementDesc;
- this.validflag = validflag;
- comBasePurchaseAgreementCtrlEntityBindingSource.DataSource = _purchaseAgreementBLL.Query(agreementDesc, validflag);
- foreach (var row in ultraGrid1.Rows)
- {
- GridEdite(row);
- }
- }
- public void Relocat(string agreementCode)
- {
- Query(agreementDesc, validflag);
- var row = ultraGrid1.Rows.Where(a => a.GetValue("AgreementCode") == agreementCode).FirstOrDefault();
- if (row != null)
- {
- row.Activate();
- }
- }
- public void Save(List<ComBasePurchaseStdIdxEntity> purchaseStdIdxs, List<ComBasePurchaseProviderEntity> purchaseProviders)
- {
- try
- {
- ultraGrid1.UpdateData();
- }
- catch
- {
- }
- var row = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True").FirstOrDefault();
- if (row == null && purchaseStdIdxs.Count == 0 && purchaseProviders.Count == 0)
- {
- MessageUtil.ShowWarning("请选择一条记录!");
- return;
- }
- ComBasePurchaseAgreementEntity purchaseAgreement = null;
- if (row != null)
- {
- purchaseAgreement = EntityHelper.CopyEntity<ComBasePurchaseAgreementEntity>(row.ListObject);
- if (row.Cells["SigningDate"].Value == null)
- {
- purchaseAgreement.SigningDate = null;
- }
- else
- {
- purchaseAgreement.SigningDate = (DateTime)row.Cells["SigningDate"].Value;
- }
- purchaseAgreement.CreateName = CoreUserInfo.UserInfo.GetUserName();
- purchaseAgreement.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
- {
- return;
- }
- string agreementCode = _purchaseAgreementBLL.Save(purchaseAgreement, purchaseProviders, purchaseStdIdxs);
- MessageUtil.ShowTips("保存成功!");
- Relocat(agreementCode);
- }
- public void UpdateValidflag(string validflag)
- {
- var row = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True").FirstOrDefault();
- if (row == null)
- {
- MessageUtil.ShowWarning("请选择一条记录!");
- return;
- }
- var purchaseAgreement = EntityHelper.CopyEntity<ComBasePurchaseAgreementEntity>(row.ListObject);
- purchaseAgreement.CreateName = CoreUserInfo.UserInfo.GetUserName();
- purchaseAgreement.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- string tips = validflag == "0" ? "作废" : "恢复";
- if (MessageUtil.ShowYesNoAndQuestion("是否确认" + tips + "?") == DialogResult.No)
- {
- return;
- }
- _purchaseAgreementBLL.UpdateValidflag(purchaseAgreement, validflag);
- MessageUtil.ShowTips(tips + "成功!");
- if (ClearData != null)
- {
- ClearData();
- }
- Relocat(purchaseAgreement.AgreementCode);
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- //this.Cursor = Cursors.WaitCursor;
- //string suppCodes = ultraGrid1.ActiveRow.GetValue("SuppCodes");
- //ComBasePurchaseProviderChoice purchaseProviderChoice = new ComBasePurchaseProviderChoice(_ob, suppCodes);
- //this.Cursor = Cursors.Default;
- //if (purchaseProviderChoice.ShowDialog() == DialogResult.OK)
- //{
- // ultraGrid1.ActiveRow.SetValue("SuppCodes", purchaseProviderChoice.SuppCodes);
- // ultraGrid1.ActiveRow.SetValue("SuppDescs", purchaseProviderChoice.SuppDescs);
- //}
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.geComBaseStdNPurchase", new object[] { }, _ob);
- dt.Columns["STD_NAME"].Caption = "内控管理编号";
- BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE", "STDSTYLE");
- baseInfoPopup.LabelTextBox1.Caption = "内控管理编号";
- baseInfoPopup.Shown += new EventHandler((a, b) =>
- {
- var actRow = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
- c => c.GetValue("STD_CODE") == ultraGrid1.ActiveRow.GetValue("StdCodeNk")).FirstOrDefault();
- if (actRow != null)
- {
- actRow.Activate();
- }
- });
- this.Cursor = Cursors.Default;
- if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- ultraGrid1.ActiveRow.SetValue("StdNameNk", baseInfoPopup.ChoicedRow.GetValue("STD_NAME"));
- ultraGrid1.ActiveRow.SetValue("StdCodeNk", baseInfoPopup.ChoicedRow.GetValue("STD_CODE"));
- }
- }
- private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
- {
- if (e.Row.GetValue("Validflag") == "无效")
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- if (ultraGrid1.ActiveCell.Column.Key != "SigningDate")
- {
- ultraGrid1.UpdateData();
- }
- if (e.Cell.Column.Key == "Chk")
- {
- UltraGridRow chkRow = e.Cell.Row;
- foreach (UltraGridRow row in ultraGrid1.Rows)
- {
- if (row.Cells["Chk"].Value.ToString() == "True" && row != chkRow)
- {
- row.Cells["Chk"].Value = "False";
- row.Update();
- }
- }
- }
- GridEdite(e.Cell.Row);
- }
- 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 ultraDateTimeEditor1_BeforeExitEditMode(object sender, Infragistics.Win.BeforeExitEditModeEventArgs e)
- {
- }
- private void ultraGrid1_BeforeCellUpdate(object sender, BeforeCellUpdateEventArgs e)
- {
- if (e.Cell.Column.Key == "SigningDate")
- {
- string strNew = e.NewValue.ToString();
- string strOld = e.Cell.Value.ToString();
- }
- }
- private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e)
- {
- if (ultraGrid1.ActiveCell.Column.Key == "SigningDate")
- {
- MessageUtil.ShowWarning("请输入正确的日期!");
- e.RaiseErrorEvent = false;
- return;
- }
- }
- }
- }
|