Ejemplo n.º 1
0
 private void btnCancel_Click(object sender, EventArgs e)
 {//取消优惠的代码逻辑
     if (CheckInput())
     {
         IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect);
         //1.删除优惠信息表的此项数据
         IPREPreferentialProvider preProvider = ProviderFactory.Create <IPREPreferentialProvider>(AppSettings.CurrentSetting.ParkConnect);
         preProvider.Delete(_CurrentPreInfo, unitWork);
         //2.将Card表的优惠时数减去
         ICardProvider cardProvider = ProviderFactory.Create <ICardProvider>(AppSettings.CurrentSetting.ParkConnect);
         CardInfo      card         = cardProvider.GetByID(_CurrentPreInfo.CardID).QueryObject;
         CardInfo      newVal       = card.Clone();
         newVal.DiscountHour -= _CurrentPreInfo.PreferentialHour;
         if (newVal.DiscountHour < 0)
         {
             newVal.DiscountHour = 0;
         }
         cardProvider.Update(newVal, card, unitWork);
         //3.保存优惠操作记录
         IPREPreferentialLogProvider preLogProvider = ProviderFactory.Create <IPREPreferentialLogProvider>(AppSettings.CurrentSetting.ParkConnect);
         PREPreferentialLog          log            = _CurrentPreInfo.CreateLog();
         log.OperatorTime    = DateTime.Now;
         log.IsCancel        = 1;
         log.CancelReason    = this.txtCancelReason.Text.Trim();
         log.WorkstationID   = PRESysOptionSetting.Current.PRESysOption.CurrentWorkstationID;
         log.WorkstationName = PRESysOptionSetting.Current.PRESysOption.CurrentWorkstation;
         log.OperatorID      = PREOperatorInfo.CurrentOperator.OperatorID;
         preLogProvider.Insert(log, unitWork);
         CommandResult result = unitWork.Commit();
         if (result.Result == ResultCode.Successful)
         {
             MessageBox.Show("取消成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ClearCardInfo();
             ClearInput();
             btnCancel.Enabled = false;
         }
         else
         {
             MessageBox.Show(result.Message);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 删除优惠信息
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 /// <exception cref=" "></exception>
 public CommandResult Delete(PREPreferentialInfo info)
 {
     return(provider.Delete(info));
 }