using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.LgResMgt.Mcms.entity; using CoreFS.CA06; namespace Core.StlMes.Client.LgResMgt.Mcms { public partial class FrmCarEff : FrmBase { public FrmCarEff() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); EntityHelper.ShowGridCaption(ugData.DisplayLayout.Bands[0]); DoQuery(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": DoQuery(); break; case "DoUpdate": DoUpdate(); break; case "DoAdd": DoAdd(); break; case "DoDelete": DoDelete(); break; case "DoRecover": DoRecover(); break; case "Export": GridHelper.ulGridToExcel(ugData, "内倒车辆"); break; case "DoClose": Close(); break; } } private void DoRecover() { if (ugData.ActiveRow == null) { MessageBox.Show("请选择需要还原的车辆数据"); return; }; CmmCarEffEntity data = ugData.ActiveRow.ListObject as CmmCarEffEntity; CmmCarEffEntity data1 = new CmmCarEffEntity() { CarNo = data.CarNo, UpdateName = this.UserInfo.GetUserName() }; var ccp = new CoreClientParam { ServerName = "com.steering.Mcms.CarEffServer", MethodName = "DoRecover", ServerParams = new object[] { JSONFormat.Format(data1), } }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.ToString2().Contains("成功")) { MessageBox.Show("成功还原车辆" + data.CarNo); DoQuery(); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void DoDelete() { if (ugData.ActiveRow == null) { MessageBox.Show("请选择需要作废的车辆数据"); return; }; CmmCarEffEntity data = ugData.ActiveRow.ListObject as CmmCarEffEntity; CmmCarEffEntity data1 = new CmmCarEffEntity() { CarNo = data.CarNo, DeleteName = this.UserInfo.GetUserName() }; var ccp = new CoreClientParam { ServerName = "com.steering.Mcms.CarEffServer", MethodName = "DoDelete", ServerParams = new object[] { JSONFormat.Format(data1), } }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.ToString2().Contains("成功")) { MessageBox.Show("成功作废车辆" + data.CarNo); DoQuery(); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void DoUpdate() { if (String.IsNullOrWhiteSpace(uteCarNoEdit.Text)) { MessageBox.Show("车牌号不能为空!"); return; } if (String.IsNullOrWhiteSpace(uneTimeEff.Text)) { MessageBox.Show("车牌皮重时效不能为空!"); return; } CmmCarEffEntity data = new CmmCarEffEntity() { CarNo = uteCarNoEdit.Text, UpdateName = this.UserInfo.GetUserName(), TimeEff = decimal.Parse(uneTimeEff.Value.ToString3()), Id = uteId.Text }; var ccp = new CoreClientParam { ServerName = "com.steering.Mcms.CarEffServer", MethodName = "DoUpdate", ServerParams = new object[] { JSONFormat.Format(data), } }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.ToString2().Contains("成功")) { MessageBox.Show("成功更新车辆" + data.CarNo); DoQuery(); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void DoAdd() { if (String.IsNullOrWhiteSpace(uteCarNoEdit.Text)) { MessageBox.Show("车牌号不能为空!"); return; } if (String.IsNullOrWhiteSpace(uneTimeEff.Text)) { MessageBox.Show("车牌皮重时效不能为空!"); return; } CmmCarEffEntity data = new CmmCarEffEntity() { CarNo = uteCarNoEdit.Text, CreateName = this.UserInfo.GetUserName(), TimeEff = decimal.Parse(uneTimeEff.Value.ToString3()) }; var ccp = new CoreClientParam { ServerName = "com.steering.Mcms.CarEffServer", MethodName = "DoAdd", ServerParams = new object[] { JSONFormat.Format(data), } }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.ToString2().Contains("成功")) { MessageBox.Show("成功新增车辆" + data.CarNo); DoQuery(); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void DoQuery() { var dic = new Dictionary(); dic.Add("carNo", uteCarNo.Text); if (chkValidflag.Checked) { dic.Add("validflag", new List() {"1", "0"}); } else { dic.Add("validflag", new List() { "1" }); } cmmCarEffEntityBindingSource.DataSource = EntityHelper.GetData( "com.steering.Mcms.CarEffServer.doQuery", new object[] { dic }, ob); Comm.RefreshAndAutoSize(ugData); } private void ugData_AfterRowActivate(object sender, EventArgs e) { if(ugData.ActiveRow==null) return; CmmCarEffEntity data = ugData.ActiveRow.ListObject as CmmCarEffEntity; uteCarNoEdit.Text = data.CarNo; uneTimeEff.Value = data.TimeEff; uteId.Text = data.Id; } private void ugData_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { CmmCarEffEntity data = e.Row.ListObject as CmmCarEffEntity; if (data != null) { if(data.Validflag=="0") e.Row.Cells["Validflag"].Appearance.BackColor= Color.Red; } } } }