private void m_TotalPaidBox_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { POSView.VoidDelegate printPaymentSuccessed = null; POSView.VoidDelegate printPaymentFailured = null; if (base.DialogResult != System.Windows.Forms.DialogResult.Cancel) { bool flag = this.TotalPaidSummRefreshed(); if (((e.KeyCode == System.Windows.Forms.Keys.Enter) && flag) && (System.Windows.Forms.DialogResult.Yes == System.Windows.Forms.MessageBox.Show("ПРИНЯТЬ ОПЛАТУ?", "ВНИМАНИЕ", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Exclamation, System.Windows.Forms.MessageBoxDefaultButton.Button1))) { decimal paid = this.m_Paid; decimal commiss = this.m_Commiss; User currentUser = User.GetCurrentUser(); string cashierTerminal = Settings.Default.CashierTerminal; ObjectList<SpPayment> payments = new ObjectList<SpPayment>(); SpPayment payment = new SpPayment { AccountId = this.m_Account.Id, Commission = commiss, Summ = paid }; payments.Add(payment); PayLocalTransaction transaction = AccountOther.MakePaymentTry(payments, currentUser.Id, cashierTerminal); AccountOther.MakeCommit(); this.m_PrintPOS.AddToAccumulatePaySum(paid, paid * this.m_Account.OrgCommission); if (printPaymentSuccessed == null) { printPaymentSuccessed = () => base.set_DialogResult(System.Windows.Forms.DialogResult.OK); } if (printPaymentFailured == null) { printPaymentFailured = () => base.set_DialogResult(System.Windows.Forms.DialogResult.OK); } this.m_PrintPOS.PrintPayment(this.m_Account, null, ((long) transaction.Id).ToString(), false, paid, paid * this.m_Account.OrgCommission, this.cbIsUseSlipDoc.get_Checked(), printPaymentSuccessed, printPaymentFailured); } } }
private void butOplApply_Click(object sender, System.EventArgs e) { if (!this.IsBusy) { this.butOplApply.set_Enabled((bool) !(this.IsBusy = true)); if (this.m_PrintPOS.IsBusy) { System.Windows.Forms.MessageBox.Show("Фискальный регистратор занят. " + System.Environment.get_NewLine() + "Дождитесь выполнения операции."); this.butOplApply.set_Enabled((bool) !(this.IsBusy = false)); } else { User currentUser; this.Payments_Fill(); ObjectList<SpPayment> payments = new ObjectList<SpPayment>(); decimal num = 0M; decimal commission = 0M; PayPaymentMoreFixedSum sum = new PayPaymentMoreFixedSum(); foreach (SpPayment payment2 in this.m_payments) { if (!(payment2.Summ == 0M)) { num += payment2.Summ; commission += payment2.Commission; SpPayment payment = new SpPayment { AccountId = payment2.AccountId, ServiceName = payment2.ServiceName, Summ = payment2.Summ, Commission = 0M }; payments.Add(payment); } } commission = decimal.Round(commission, 2); if (payments.get_Count() == 0) { this.butOplApply.set_Enabled((bool) !(this.IsBusy = false)); throw new System.ApplicationException("Ошибка, нет ни одной услуги для оплаты, проверте суммы оплаты."); } payments.get_Item(0).Commission = commission; string cashierTerminal = Settings.Default.CashierTerminal; if (num >= PersonsCashSearchForm.FixedSumm) { PersonsCashSearchForm form = new PersonsCashSearchForm(); if (form.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { base.Close(); return; } sum.PersonId = form.SelectPerson.Id; } try { currentUser = User.GetCurrentUser(); currentUser.GetOrg(); } catch (System.Exception) { this.butOplApply.set_Enabled((bool) !(this.IsBusy = false)); throw new System.ApplicationException("Ошибка, проверьте настройки пользователя, организаций пункта приема и платежного агента."); } sum.UserId = currentUser.Id; PayLocalTransaction transaction = AccountOther.MakePaymentTry(payments, currentUser.Id, cashierTerminal); AccountOther.MakeCommit(); if (num >= PersonsCashSearchForm.FixedSumm) { sum.SpPaymentUno = transaction.Id; sum.Summ = num; sum.SaveChanges(); } this.m_PrintPOS.AddToAccumulatePaySum(num, commission); this.m_PrintPOS.PrintPayment(this.m_Accounts.get_Item(0), payments, ((long) transaction.Id).ToString(), false, num, commission, false, delegate { Messages.ShowMessage("Платеж успешно проведен."); this.butOplApply.set_Enabled((bool) !(this.IsBusy = false)); base.Close(); }, delegate { Messages.ShowMessage("Платеж успешно проведен."); this.butOplApply.set_Enabled((bool) !(this.IsBusy = false)); base.Close(); }); } } }
private void Payments_Fill() { decimal num5; this.m_dgServices_Cell_Editing = true; this.m_payments = new ObjectList<SpPayment>(); decimal num = 0M; decimal num2 = 0M; foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgServices.Rows) { AccountOther other = row.get_DataBoundItem() as AccountOther; if (other != null) { decimal num3; string raw = (row.Cells.get_Item("SumPay").get_Value() == null) ? ((string) "0.00") : row.Cells.get_Item("SumPay").get_Value().ToString(); if (!this.CorrectAndGetInputSumm(ref raw, out num3, true)) { row.Cells.get_Item("SumPay").set_Value("0.00"); return; } if (num3 < 0M) { Messages.ShowError("Сумма оплаты должна быть положительным числом"); } row.Cells.get_Item("SumPay").set_Value(raw); num += num3; decimal num4 = num3 * other.OrgCommission; num2 += num4; SpPayment payment = new SpPayment { AccountId = other.Id, ServiceName = other.ServiceName, Summ = num3, Commission = num4 }; this.m_payments.Add(payment); } } num2 = decimal.Round(num2, 2); if (!decimal.TryParse(this.tbSumOpl.get_Text(), ref num5) || (num5 != num)) { this.m_tbSumOpl_Editing = true; this.tbSumOpl.set_Text(num.ToString(this.m_NumberFormat)); this.m_tbSumOpl_Editing = false; } if (num == 0M) { this.tbSumEndKomm.set_Text("0.00"); this.tbSumEndOpl.set_Text("0.00"); } else { this.tbSumEndKomm.set_Text(num2.ToString(this.m_NumberFormat)); this.tbSumEndOpl.set_Text((num2 + num).ToString(this.m_NumberFormat)); } this.m_dgServices_Cell_Editing = false; }
public void Print(PayRequest payment, PayRequest paymentForServices, bool isCancelPayment) { if (this.IsUseFiscalDocument.Value) { AccountOther other; ObjectList<PayRequestAccountService> requestAccountServices = paymentForServices.GetRequestAccountServices(); ObjectList<SpPayment> services = new ObjectList<SpPayment>(); foreach (PayRequestAccountService service in requestAccountServices) { SpPayment payment2 = new SpPayment { ServiceName = service.Name, Summ = service.Paid }; services.Add(payment2); } ObjectList<AccountOther> infoOrgFromRequestAccountServices = AccountOther.GetInfoOrgFromRequestAccountServices(paymentForServices.Id); if ((infoOrgFromRequestAccountServices != null) && (infoOrgFromRequestAccountServices.get_Count() > 0)) { other = infoOrgFromRequestAccountServices.get_Item(0); } else { other = new AccountOther(); } this.PrintPayment(other, services, payment.ExternalTransactionId, isCancelPayment, payment.PaidSumm, paymentForServices.Commission, false, null, null); } }