Beispiel #1
0
 private void m_ProcessPayment(object sender, System.DateTime period)
 {
     if (this.m_Request == null)
     {
         Messages.ShowError("ОПЛАТА НЕВОЗМОЖНА. ЗАКРОЙТЕ И ОТКРОЙТЕ ФОРМУ ПЛАТЕЖЕЙ");
     }
     else
     {
         lock (LockProcessPayment)
         {
             PayPaymentMoreFixedSum sum = new PayPaymentMoreFixedSum();
             if (this.m_TotalPaid >= PersonsCashSearchForm.FixedSumm)
             {
                 PersonsCashSearchForm form = new PersonsCashSearchForm();
                 if (form.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                 {
                     base.ParentForm.Close();
                     goto Label_0374;
                 }
                 sum.PersonId = form.SelectPerson.Id;
             }
             PayRequest payment = null;
             bool flag = false;
             try
             {
                 DALSql.ExecuteNonQuery("begin transaction", null);
                 this.m_Request.IsConfirmed = true;
                 this.m_Request.ConfirmedAt = DALSql.GetDatabaseTime();
                 this.m_Request.PaidSumm = this.m_TotalPaid;
                 this.m_Request.RequestTypeFasetId = Mappers.FasetItemMapper.FindByName(FasetsEnum.PaymentOperationType, "Оплата наличными").Id;
                 this.m_Request.IsManualReturn = Settings.Default.CashierReturnMode;
                 PayLocalTransaction transaction = new PayLocalTransaction {
                     RequestId = this.m_Request.Id
                 };
                 transaction.SaveChanges();
                 this.m_Request.ExternalTransactionId = ((long) transaction.Id).ToString();
                 this.m_Request.AgentId = this.m_Agent.Id;
                 this.m_Request.PackNumber = this.m_PackNumber;
                 this.m_Request.PaymentOrderNumber = this.m_OrderNumber;
                 this.m_Request.PaymentOrderDate = this.m_OrderDate;
                 this.m_Request.PaymentOrderPackId = this.m_PaymentOrderPackId;
                 this.m_Request.UseBankrupt = this.chbxUseAccountServiceBankrupts.get_Checked();
                 this.m_Request.NeedServiceCollapse = Settings.Default.NeedServiceCollapse;
                 this.m_Request.SubService = this.m_subService;
                 this.m_Request.SaveChanges();
                 ObjectList<PayRequestCounter> list = this.m_PayRequestCounters.get_DataSource() as ObjectList<PayRequestCounter>;
                 if (list != null)
                 {
                     foreach (PayRequestCounter counter in list)
                     {
                         counter.SaveChanges();
                     }
                 }
                 this.m_Request.ProcessPayment();
                 this.m_Request.ProcessPayment_ValidateSumm();
                 if (this.m_TotalPaid >= PersonsCashSearchForm.FixedSumm)
                 {
                     PayRequest request2 = ObjectWithId.FindById<PayRequest>(this.m_Request.Id);
                     sum.GroupOperationId = request2.GroupOperId;
                     sum.SpPaymentUno = transaction.Id;
                     sum.UserId = User.CurrentUser.Id;
                     sum.Summ = this.m_TotalPaid;
                     sum.SaveChanges();
                 }
                 DALSql.ExecuteNonQuery("commit transaction", null);
                 payment = this.m_Request;
                 this.m_Request = null;
                 if (!Settings.Default.CashierQuestApplyPrintPayment || (System.Windows.Forms.DialogResult.Yes == System.Windows.Forms.MessageBox.Show(null, "ОПЛАТА ПРОВЕДЕНА УСПЕШНО. ПЕЧАТАТЬ КВИТАНЦИЮ?", "ПЕЧАТЬ КВИТАНЦИИ", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Exclamation, System.Windows.Forms.MessageBoxDefaultButton.Button1)))
                 {
                     flag = true;
                 }
                 if (!Settings.Default.CashierReturnMode)
                 {
                     this.m_posView.AddToAccumulatePaySum(payment.PaidSumm, payment.Commission);
                 }
                 else
                 {
                     this.m_posView.AddToAccumulatePaySum(-payment.PaidSumm, -payment.Commission);
                 }
             }
             catch (System.Exception exception)
             {
                 try
                 {
                     DALSql.ExecuteNonQuery("rollback transaction", null);
                 }
                 catch (System.Exception)
                 {
                 }
                 throw new System.ApplicationException("Возникла ошибка при проведении платежа", exception);
             }
             finally
             {
                 this.m_PaymentButton.set_Image(null);
                 if (flag)
                 {
                     this.m_posView.Print(payment, payment, Settings.Default.CashierReturnMode);
                     if (!Settings.Default.CashierReturnMode)
                     {
                         ReceiptReport.ShowDialog(this, payment);
                     }
                 }
                 base.ParentForm.set_DialogResult(System.Windows.Forms.DialogResult.OK);
             }
         Label_0374:;
         }
     }
 }
Beispiel #2
0
 public PayRequest Reverse(string terminal)
 {
     if (base.Id < 0L)
     {
         throw new System.ApplicationException("Ошибка! Дополнительный платеж должен быть отменен через POSView.");
     }
     if (!this.IsProcessed)
     {
         throw new System.ApplicationException("Платеж еще не проведен. Дождитесь проводки платежа.");
     }
     if (this.ReverseRequestId != 0L)
     {
         throw new System.ApplicationException("Платеж уже был возвращен. Повторный возврат невозможен.");
     }
     PayRequest request = new PayRequest {
         PaymentSystem = LocalPaymentSystem,
         Organization = Constants.OrgName,
         Terminal = terminal,
         Operator = User.CurrentUser.Name,
         AccountNumber = this.AccountNumber,
         Period = this.Period,
         AccountId = this.AccountId,
         AddressName = this.AddressName,
         OwnerName = this.OwnerName,
         PaidSumm = this.PaidSumm,
         AgentId = this.AgentId,
         AgentName = this.AgentName,
         PaymentOrderNumber = this.PaymentOrderNumber,
         PackNumber = this.PackNumber,
         PaymentOrderDate = this.PaymentOrderDate,
         Commission = this.Commission,
         RequestTypeFasetId = Mappers.FasetItemMapper.FindByName(FasetsEnum.PaymentOperationType, "Возврат оплаты наличными").Id,
         CashFlowTypeId = this.CashFlowTypeId
     };
     request.SaveChanges();
     request.IsConfirmed = true;
     request.ConfirmedAt = Register.GetDatabaseTime();
     PayLocalTransaction transaction = new PayLocalTransaction {
         RequestId = request.Id
     };
     transaction.SaveChanges();
     request.ExternalTransactionId = ((long) transaction.Id).ToString();
     request.ReverseRequestId = base.Id;
     request.UsePaymentDate = this.UsePaymentDate;
     request.SaveChanges();
     this.ReverseRequestId = request.Id;
     this.SaveChanges();
     request.ProcessPayment();
     return request;
 }