private void mnu_PrintRecord_Click(object sender, EventArgs e)
 {
     try
     {
         DataGridViewRow    row = GridView.SelectedRows[0];
         PREPreferentialLog Log = row.Tag as PREPreferentialLog;
         if (Log != null)
         {
             string path  = string.Empty;
             string modal = System.IO.Path.Combine(Application.StartupPath, @"ReportModal\PreferentialLogReportModal.xls");
             ExcelExport.MonthCardReportToExcel ose = null;
             if (System.IO.File.Exists(modal))
             {
                 ose = new ExcelExport.MonthCardReportToExcel(modal);
                 ose.PrintByExcel(Log);
             }
             else
             {
                 MessageBox.Show("未找到打印模板!", "提示");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "警告");
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
 }
        private void FillPreferentialLog(Worksheet sheet, PREPreferentialLog preLog, int row)
        {
            Range r = sheet.get_Range("A" + row, Type.Missing);

            r.Value2 = PREOperatorInfo.CurrentOperator.OperatorName;                //打印操作员
            r        = sheet.get_Range("B" + row, Type.Missing);
            r.Value2 = string.Empty;                                                //优惠总时数
            r        = sheet.get_Range("C" + row, Type.Missing);
            r.Value2 = PRESysOptionSetting.Current.PRESysOption.CurrentWorkstation; //打印工作站
            r        = sheet.get_Range("D" + row, Type.Missing);
            r.Value2 = DateTime.Now;                                                //打印时间
        }
 private void ShowPreferentialLogOnRow(PREPreferentialLog info, int row)
 {
     GridView.Rows[row].Tag = info;
     GridView.Rows[row].Cells["colCardID"].Value           = info.CardID;
     GridView.Rows[row].Cells["colEntranceTime"].Value     = info.EntranceTime;
     GridView.Rows[row].Cells["colPreferentialHour"].Value = info.PreferentialHour;
     GridView.Rows[row].Cells["colBusiness1"].Value        = info.BusinessesName1;
     GridView.Rows[row].Cells["colCost1"].Value            = info.BusinessesMoney1;
     GridView.Rows[row].Cells["colBusiness2"].Value        = info.BusinessesName2;
     GridView.Rows[row].Cells["colCost2"].Value            = info.BusinessesMoney2;
     GridView.Rows[row].Cells["colBusiness3"].Value        = info.BusinessesName3;
     GridView.Rows[row].Cells["colCost3"].Value            = info.BusinessesMoney3;
     GridView.Rows[row].Cells["colNotes"].Value            = info.Notes;
     GridView.Rows[row].Cells["colWorkstationName"].Value  = info.WorkstationName;
     GridView.Rows[row].Cells["colOperator"].Value         = info.Operator.OperatorName;
     GridView.Rows[row].Cells["colOperatorTime"].Value     = info.OperatorTime;
     GridView.Rows[row].Cells["colIsCancel"].Value         = info.IsCancel == 1 ? "是" : string.Empty;
     GridView.Rows[row].Cells["colCancelReason"].Value     = info.CancelReason;
 }
 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);
         }
     }
 }
        /// <summary>
        /// 导出优惠记录到Excel中,并直接打印出来
        /// </summary>
        /// <param name="preLog"></param>
        public void PrintByExcel(PREPreferentialLog preLog)
        {
            PreferentialReportSearchCondition recordCon = new PreferentialReportSearchCondition();

            recordCon.CardID = preLog.CardID;
            Application app  = new Application();
            Workbook    book = null;

            book = app.Workbooks.Add(ReportModal);
            Worksheet sheet = book.ActiveSheet as Worksheet;

            FillPreferentialLog(sheet, preLog, 3);

            PREPreferentialLogBll     bll  = new PREPreferentialLogBll(AppSettings.CurrentSetting.ParkConnect);
            List <PREPreferentialLog> logs = bll.GetPreferentials(recordCon).QueryObjects;

            FillDetail(sheet, logs, 6);
            sheet.PrintOutEx(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            book.Close(false, Type.Missing, Type.Missing);
        }
Exemple #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                PREPreferentialInfo info = GetItemFromInput();
                //1.插入优惠信息
                IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect);
                IPREPreferentialProvider preProvider = ProviderFactory.Create <IPREPreferentialProvider>(AppSettings.CurrentSetting.ParkConnect);
                preProvider.Insert(info, unitWork);
                //2.更新卡片的优惠信息

                ICardProvider cardProvider = ProviderFactory.Create <ICardProvider>(AppSettings.CurrentSetting.ParkConnect);
                CardInfo      card         = cardProvider.GetByID(info.CardID).QueryObject;
                if (card == null)
                {
                    MessageBox.Show("没有此卡片!");
                    return;
                }
                CardInfo newCard = card.Clone();
                newCard.DiscountHour    += info.PreferentialHour;
                newCard.PreferentialTime = info.PreferentialTime;
                cardProvider.Update(newCard, card, unitWork);
                //3.保存优惠操作记录
                IPREPreferentialLogProvider logProvider = ProviderFactory.Create <IPREPreferentialLogProvider>(AppSettings.CurrentSetting.ParkConnect);
                PREPreferentialLog          log         = info.CreateLog();
                log.OperatorTime = DateTime.Now;
                logProvider.Insert(log, unitWork);
                CommandResult result = unitWork.Commit();
                if (result.Result == ResultCode.Successful)
                {
                    MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearInput();
                }
                else
                {
                    MessageBox.Show(result.Message);
                }
            }
        }
 /// <summary>
 /// 增加优惠信息
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public CommandResult Insert(PREPreferentialLog info)
 {
     return(provider.Insert(info));
 }