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 WMS.Frm.Base; using WMS.Model.Base; using WMS.Base.WebService; using WMS.Common; namespace WMS.FrmBaseData { /// /// 窗体:快递公司信息编辑 /// public partial class FrmLogisticsComInfoHandle : FormBase { #region 变量 private LogisticsComInfoModel LogisticsComInfoModel = new LogisticsComInfoModel(); public int flag = -1;//0:新增;1:修改;3:编辑导入的数据 #endregion #region 初始化 /// /// 构造函数 用于新增 /// public FrmLogisticsComInfoHandle() { InitializeComponent(); flag = 0; bsLogisticsComInfo.DataSource = LogisticsComInfoModel; } /// /// 构造函数 用于修改 /// /// public FrmLogisticsComInfoHandle(LogisticsComInfoModel LogisticsComInfo) { InitializeComponent(); flag = 1; LogisticsComInfoModel = LogisticsComInfo; bsLogisticsComInfo.DataSource = LogisticsComInfoModel; } /// /// load /// /// /// private void FrmLogisticsComInfoHandle_Load(object sender, EventArgs e) { } #endregion #region 按钮事件 /// /// 确定按钮 /// /// /// private void ctrlButtons1_Click(object sender, EventArgs e) { btnConfirm.Focus(); //非空验证 if (string.IsNullOrEmpty(txtComName.Text.Trim())) { SystemCommon.ShowInfoMessageBox("快递公司名称不能为空"); txtComName.Focus(); return; } LogisticsComInfoModel model = LogisticsComInfoModel; model.OPERATORID = userData.USER_ID;//操作人 if (flag == 1)//修改 { string strLogisticsComInfoModel = Newtonsoft.Json.JsonConvert.SerializeObject(model); string errText = string.Empty; try { errText = WebLockConfig.Instance.WebLogisticsComInfo.InsOrUpdLogisticsComInfo(strLogisticsComInfoModel, 1); if (string.IsNullOrEmpty(errText)) { SystemCommon.ShowInfoMessageBox("修改成功"); } else { SystemCommon.ShowInfoMessageBox("修改失败" + errText); } } catch (Exception) { SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } else if (flag == 0)//新增 { string strLogisticsComInfoModel = Newtonsoft.Json.JsonConvert.SerializeObject(model); string errText = string.Empty; try { errText = WebLockConfig.Instance.WebLogisticsComInfo.InsOrUpdLogisticsComInfo(strLogisticsComInfoModel, 0); if (string.IsNullOrEmpty(errText)) { SystemCommon.ShowInfoMessageBox("新增成功"); } else { SystemCommon.ShowInfoMessageBox("新增失败" + errText); } } catch (Exception) { SystemCommon.ShowInfoMessageBox("未知错误,请检查网络连接!如仍无法解决问题请联系我们!"); } } this.Close(); this.Dispose(); } /// /// 退出按钮 /// /// /// private void ctrlButtons2_Click(object sender, EventArgs e) { if (DialogResult.Yes != SystemCommon.ShowMessageBoxResult("确定放弃正在编辑的数据?")) { return; } this.Close(); this.Dispose(); } #endregion } }