using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.SaleBase.model; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.SaleBase { public partial class SlmBaseCustStorage : FrmBase { SlmBaseCustStorageEntity entity; public SlmBaseCustStorageEntity Entity { get { return entity; } set { entity = value; } } public SlmBaseCustStorage() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); } public override void ToolBar_Click(object sender, string ToolbarKey) { base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "doQuery": Query(); break; case "doAdd": Add(); break; case "doUpdate": Update(); break; case "doDelete": Delete(); break; case "doRecovery": Recovery(); break; case "doClose": this.Close(); break; } } private void Recovery() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); ArrayList parms = new ArrayList(); foreach (UltraGridRow row in checkRows) { SlmBaseCustStorageEntity parm = row.ListObject as SlmBaseCustStorageEntity; parm.UpdateName = this.UserInfo.GetUserName(); parms.Add(JSONFormat.Format(parm)); } if (MessageUtil.ShowYesNoAndQuestion("是否确认恢复记录?") == DialogResult.No) { return; } List jsons = new List(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.base.SlmBaseCustStorage"; ccp.MethodName = "UpdateValidflag"; ccp.ServerParams = new object[] { parms, "1" }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("恢复成功!"); Query(); } } private void Delete() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); ArrayList parms = new ArrayList(); foreach (UltraGridRow row in checkRows) { SlmBaseCustStorageEntity parm = row.ListObject as SlmBaseCustStorageEntity; parm.DeleteName = this.UserInfo.GetUserName(); parms.Add(JSONFormat.Format(parm)); } if (MessageUtil.ShowYesNoAndQuestion("是否确认作废记录?") == DialogResult.No) { return; } List jsons = new List(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.base.SlmBaseCustStorage"; ccp.MethodName = "UpdateValidflag"; ccp.ServerParams = new object[] { parms, "0" }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("作废成功!"); Query(); } } private void Update() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); ArrayList parms = new ArrayList(); foreach (UltraGridRow row in checkRows) { SlmBaseCustStorageEntity parm = row.ListObject as SlmBaseCustStorageEntity; parm.CustomerNo = row.Cells["CustomerNM"].Value.ToString2(); parm.CustomerNm = row.Cells["CustomerNM"].Text.ToString2(); parm.StorageNo = row.Cells["StorageName"].Value.ToString2(); parm.StorageName = row.Cells["StorageName"].Text.ToString2(); parm.UpdateName = this.UserInfo.GetUserName(); parms.Add(JSONFormat.Format(parm)); } if (MessageUtil.ShowYesNoAndQuestion("是否确认修改记录?") == DialogResult.No) { return; } List jsons = new List(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.base.SlmBaseCustStorage"; ccp.MethodName = "Update"; ccp.ServerParams = new object[] { parms }; ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("修改成功!"); Query(); } } private void Add() { this.ultraGrid1.UpdateData(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True"); ArrayList parms = new ArrayList(); foreach (UltraGridRow row in checkRows) { SlmBaseCustStorageEntity parm = row.ListObject as SlmBaseCustStorageEntity; parm.CustomerNo = row.Cells["CustomerNM"].Value.ToString2(); parm.CustomerNm = row.Cells["CustomerNM"].Text.ToString2(); parm.StorageNo = row.Cells["StorageName"].Value.ToString2(); parm.StorageName = row.Cells["StorageName"].Text.ToString2(); parm.CreateName = this.UserInfo.GetUserName(); parms.Add(JSONFormat.Format(parm)); } if (MessageUtil.ShowYesNoAndQuestion("是否确认新增记录?") == DialogResult.No) { return; } List jsons = new List(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.base.SlmBaseCustStorage"; ccp.MethodName = "Insert"; ccp.ServerParams = new object[] { parms }; //ccp.IfShowErrMsg = false; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("新增成功!"); Query(); } } private void Query() { string storageName = labelTextBox1.CheckBox.Checked ? labelTextBox1.Text.Trim() : ""; string customerNm = labelTextBox2.CheckBox.Checked ? labelTextBox2.Text.Trim() : ""; string flag = ultraCheckEditor1.Checked ? "0" : "1"; List listSource = EntityHelper.GetData( "com.steering.pss.sale.base.SlmBaseCustStorage.Query", new object[] { storageName, customerNm, flag }, this.ob); slmBaseCustStorageEntityBindingSource.DataSource = listSource; } private void SlmBaseCustStorage_Load(object sender, EventArgs e) { // 查询仓库 DataTable dt = ServerHelper.GetData("com.steering.pss.sale.base.SlmBaseCustStorage.QueryStorage", null, this.ob); Storage_S.DataSource = dt; Storage_S.DisplayMember = "STORAGE_NAME"; Storage_S.ValueMember = "STORAGE_NO"; Storage_S.DataBind(); // 查询客户 DataTable dt1 = ServerHelper.GetData("com.steering.pss.sale.base.SlmBaseCustStorage.QueryCustomer", null, this.ob); Customer_S.DataSource = dt1; Customer_S.DisplayMember = "CUSTOMER_NM"; Customer_S.ValueMember = "CUSTOMER_NO"; Customer_S.DataBind(); Query(); } } }