/// <summary> /// 编辑状态下的数据保存 /// </summary> /// <returns></returns> public override bool SaveUpdated() { ConsignmentInfo info = BLLFactory <Consignment> .Instance.FindById(Id); if (info != null) { SetInfo(info); try { #region 更新数据 Int32 succeed = BLLFactory <Consignment> .Instance.UpdateConsignmentById(info); if (succeed > 0) { //可添加其他关联操作 MessageDxUtil.ShowTips("操作成功"); return(true); } #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditConsignment)); MessageDxUtil.ShowError(ex.Message); } } return(false); }
/// <summary> /// 编辑或者保存状态下取值函数 /// </summary> /// <param name="info"></param> private void SetInfo(ConsignmentInfo info) { // 如果没有ID值则为新增 if (info.Id == 0) { info.Id = BLLFactory <Consignment> .Instance.GetMaxId() + 1; } // 这里可以写日志 查看变更内容 info.Name = txtName.Text.Trim(); info.StrValue = txtStrValue.Text.Trim(); info.SysValue = txtSysValue.Text.Trim(); info.EnableStatus = (short)(ccbEnableStatus.SelectedDataRow as DicKeyValueInfo).DicttypeValue; }
/// <summary> /// 数据显示的函数 /// </summary> public override void DisplayData() { if (Id > 0) { #region 显示客户信息 ConsignmentInfo info = BLLFactory <Consignment> .Instance.FindById(Id); if (info != null) { txtStrValue.Text = info.StrValue; txtSysValue.Text = info.SysValue; txtName.Text = info.Name; ccbEnableStatus.EditValue = (Int32)info.EnableStatus; } #endregion } }
/// <summary> /// 新增状态下的数据保存 /// </summary> /// <returns></returns> public override bool SaveAddNew() { //检查不同ID是否还有其他相同关键字的记录 string condition = string.Format("StrValue ='{0}' ", txtStrValue.Text.Trim()); bool exist = BLLFactory <Consignment> .Instance.IsExistRecord(condition); if (exist) { MessageDxUtil.ShowTips("指定的【小账号】已经存在,请修改"); return(false); } condition = string.Format("SysValue ='{0}' ", txtSysValue.Text.Trim()); exist = BLLFactory <Consignment> .Instance.IsExistRecord(condition); if (exist && !string.Equals(txtSysValue.Text.Trim(), "无")) { MessageDxUtil.ShowTips("指定的【代销商号】已经存在,请修改"); return(false); } ConsignmentInfo consignmentInfo = new ConsignmentInfo(); SetInfo(consignmentInfo); try { #region 新增数据 Int32 succeed = BLLFactory <Consignment> .Instance.InsertConsignment(consignmentInfo); if (succeed > 0) { MessageDxUtil.ShowTips("操作成功"); return(true); } #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditConsignment)); MessageDxUtil.ShowError(ex.Message); } return(false); }