using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Qcm.BLL; using Core.StlMes.Client.Qcm.model; using CoreFS.CA06; using System; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm.Control { public partial class ComBaseSuppCtrl : UserControl { private ComBaseSuppBLL _suppBLL; private ComBaseSuppAptitudeBLL _suppAptitudeBLL; private ComBaseSuppBankBLL _suppBankBLL; private ComBasePurchaseRangeCtrl _purchaseRangeCtrl; public ComBasePurchaseRangeCtrl PurchaseRangeCtrl { get { return _purchaseRangeCtrl; } set { _purchaseRangeCtrl = value; } } public ComBaseSuppCtrl(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); _purchaseRangeCtrl = new ComBasePurchaseRangeCtrl(ultraGroupBox3, ob); _suppBLL = new ComBaseSuppBLL(ob); _suppAptitudeBLL = new ComBaseSuppAptitudeBLL(ob); _suppBankBLL = new ComBaseSuppBankBLL(ob); container.Controls.Add(this); this.Dock = DockStyle.Fill; } private string _suppCode = ""; private string _suppName = ""; private string _suppLinkMan = ""; private string _validflag = ""; public void Query(string suppCode, string suppName, string suppLinkMan, string validflag) { _suppCode = suppCode; _suppName = suppName; _suppLinkMan = suppLinkMan; _validflag = validflag; dataTable2.Clear(); dataTable3.Clear(); DataTable dtSupp = _suppBLL.Query(suppCode, suppName, suppLinkMan, validflag); GridHelper.CopyDataToDatatable(dtSupp, dataTable1, true); } public void QuerySuppAptitude() { DataTable dtSuppAptitude = _suppAptitudeBLL.Query(ultraGrid1.GetActiveRowValue("suppCode")); GridHelper.CopyDataToDatatable(dtSuppAptitude, dataTable3, true); } public void QuerySuppBank() { DataTable dtSuppBank = _suppBankBLL.Query(ultraGrid1.GetActiveRowValue("suppCode")); GridHelper.CopyDataToDatatable(dtSuppBank, dataTable2, true); } public void RelocateSupp(string suppCode) { Query(_suppCode, _suppName, _suppLinkMan, _validflag); var row = ultraGrid1.Rows.Where(a => a.GetValue("suppCode") == suppCode).FirstOrDefault(); if (row != null) { row.Activate(); } } private void RelocateSuppAptitude(string id) { QuerySuppAptitude(); var row = ultraGrid3.Rows.Where(a => a.GetValue("id") == id).FirstOrDefault(); if (row != null) { row.Activate(); } } private void RelocateSuppBank(string id) { QuerySuppBank(); var row = ultraGrid2.Rows.Where(a => a.GetValue("id") == id).FirstOrDefault(); if (row != null) { row.Activate(); } } public void AddSupp(ComBaseSuppEntity suppEntity) { if (MessageUtil.ShowYesNoAndQuestion("是否确认新增记录?") == DialogResult.No) { return; } string suppCode = _suppBLL.Insert(suppEntity); RelocateSupp(suppCode); MessageUtil.ShowTips("新增成功!"); } public void AddSuppAptitude(ComBaseSuppAptitudeEntity suppAptitude) { if (MessageUtil.ShowYesNoAndQuestion("是否确认新增记录?") == DialogResult.No) { return; } string id = _suppAptitudeBLL.Insert(suppAptitude); RelocateSuppAptitude(id); MessageUtil.ShowTips("新增成功!"); } public void AddSuppBank(ComBaseSuppBankEntity suppBank) { if (MessageUtil.ShowYesNoAndQuestion("是否确认新增记录?") == DialogResult.No) { return; } string id = _suppBankBLL.Insert(suppBank); RelocateSuppBank(id); MessageUtil.ShowTips("新增成功!"); } public void ModifySupp(ComBaseSuppEntity suppEntity) { if (MessageUtil.ShowYesNoAndQuestion("是否确认修改记录?") == DialogResult.No) { return; } _suppBLL.Update(suppEntity); RelocateSupp(suppEntity.SuppCode); MessageUtil.ShowTips("修改成功!"); } public void ModifySuppAptitude(ComBaseSuppAptitudeEntity suppAptitude) { if (MessageUtil.ShowYesNoAndQuestion("是否确认修改记录?") == DialogResult.No) { return; } _suppAptitudeBLL.Update(suppAptitude); RelocateSuppAptitude(suppAptitude.Id); MessageUtil.ShowTips("修改成功!"); } public void ModifySuppBank(ComBaseSuppBankEntity suppBank) { if (MessageUtil.ShowYesNoAndQuestion("是否确认修改记录?") == DialogResult.No) { return; } _suppBankBLL.Update(suppBank); RelocateSuppBank(suppBank.Id); MessageUtil.ShowTips("修改成功!"); } public void UpdateSuppValidflag(ComBaseSuppEntity suppEntity, string validflag) { string tip = validflag == "1" ? "恢复" : "作废"; if (MessageUtil.ShowYesNoAndQuestion("是否确认" + tip + "记录?") == DialogResult.No) { return; } _suppBLL.UpdateValidflag(suppEntity, validflag); RelocateSupp(suppEntity.SuppCode); MessageUtil.ShowTips(tip + "成功!"); } public void DeleteSuppAptitude(ComBaseSuppAptitudeEntity suppAptitude) { if (MessageUtil.ShowYesNoAndQuestion("是否确认删除记录?") == DialogResult.No) { return; } _suppAptitudeBLL.Delete(suppAptitude); RelocateSuppAptitude(suppAptitude.Id); MessageUtil.ShowTips("删除成功!"); } public void DeleteSuppBank(ComBaseSuppBankEntity suppBank) { if (MessageUtil.ShowYesNoAndQuestion("是否确认删除记录?") == DialogResult.No) { return; } _suppBankBLL.Delete(suppBank); RelocateSuppBank(suppBank.Id); MessageUtil.ShowTips("删除成功!"); } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { } private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { if (e.Row.GetValue("Validflag") == "无效") { e.Row.Appearance.ForeColor = Color.Red; } } } }