コード例 #1
0
        protected void ToolbarButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == @"Payment Confirm" && !string.IsNullOrEmpty(hfInvoiceId.Value) && (btCheckPayment.Checked || btCheckCredit.Checked) && !string.IsNullOrEmpty(Convert.ToString(tbPaymentDate.SelectedDate)))
            {
                if (IsValid)
                {
                    var paymentAddChk = false;
                    var creditAddChk  = 0;

                    if (btCheckPayment.Checked && tbPaymentAmount.Value > 0)
                    {
                        var cPayment   = new CPayment();
                        var newPayment = new Erp2016.Lib.Payment();

                        newPayment.InvoiceId   = Convert.ToInt32(hfInvoiceId.Value);
                        newPayment.PaymentDate = Convert.ToDateTime(tbPaymentDate.SelectedDate);
                        newPayment.Method      = Convert.ToInt32(ddlPyamentMethod.SelectedValue);
                        newPayment.Currency    = Convert.ToInt32(ddlCurrency.SelectedValue);
                        newPayment.Amount      = Convert.ToDecimal(tbPaymentAmount.Value);
                        newPayment.Remark      = tbRemark.Text;

                        newPayment.SiteLocationId = CurrentSiteLocationId;
                        newPayment.CreatedId      = CurrentUserId;
                        newPayment.CreatedDate    = DateTime.Now;

                        paymentAddChk = cPayment.Add(newPayment) > 0;
                    }

                    if (btCheckCredit.Checked && tbCreditAmount.Value > 0)
                    {
                        var cPayment      = new CPayment();
                        var creditPayment = new Erp2016.Lib.Payment();

                        creditPayment.InvoiceId   = Convert.ToInt32(hfInvoiceId.Value);
                        creditPayment.PaymentDate = Convert.ToDateTime(tbPaymentDate.SelectedDate);
                        creditPayment.Method      = 9; //Payment Method : Credit Memo

                        creditPayment.Amount = Convert.ToDecimal(tbCreditAmount.Value);
                        creditPayment.Remark = tbRemark.Text;

                        creditPayment.SiteLocationId = CurrentSiteLocationId;
                        creditPayment.CreatedId      = CurrentUserId;
                        creditPayment.CreatedDate    = DateTime.Now;

                        creditAddChk = cPayment.Add(creditPayment);

                        if (creditAddChk > 0)
                        {
                            var cCrreditHistory = new CCreditMemoCreditHistory();
                            var creditHistory   = new Erp2016.Lib.CreditMemoCreditHistory();

                            creditHistory.CreditMemoId = Convert.ToInt32(ddlCreditMemo.SelectedValue);
                            creditHistory.PayoutMethod = 1; //CreditPayMethod(1218) : Credit(1)
                            creditHistory.CreditAmount = Convert.ToDecimal(tbCreditAmount.Value);
                            creditHistory.CreditDate   = Convert.ToDateTime(tbPaymentDate.SelectedDate);
                            creditHistory.PaymentId    = creditAddChk;
                            creditHistory.CreatedId    = CurrentUserId;
                            creditHistory.CreatedDate  = DateTime.Now;

                            cCrreditHistory.Add(creditHistory);
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Add CreditMemoPayoutHistory)");
                        }
                    }

                    if (btCheckPayment.Checked && btCheckCredit.Checked)
                    {
                        if (paymentAddChk && creditAddChk > 0)
                        {
                            RunClientScript("Close();");
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Add Payment)");
                        }
                    }
                    else
                    {
                        if (btCheckPayment.Checked)
                        {
                            if (paymentAddChk)
                            {
                                RunClientScript("Close();");
                            }
                            else
                            {
                                ShowMessage("failed to update inqury (General Pay)");
                            }
                        }
                        else if (btCheckCredit.Checked)
                        {
                            if (creditAddChk > 0)
                            {
                                RunClientScript("Close();");
                            }
                            else
                            {
                                ShowMessage("failed to update inqury (Credit Pay)");
                            }
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (System failed)");
                        }
                    }
                }
            }
            else if (e.Item.Text == "Cancel")
            {
                RunClientScript("Close();");
            }
            else
            {
                ShowMessage("Check Pay Info");
            }
        }
コード例 #2
0
        protected void RadToolBarPayment_OnButtonClick(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "New Payment":
                if (RadGridPayment.SelectedValue != null)
                {
                    RunClientScript("ShowNewPaymentWindow('" + RadGridPayment.SelectedValue + "');");
                }
                break;

            case "Agency Detail Reciept":
                if (_radGridPaymentHistory.SelectedValue != null)
                {
                    var selectedInvoiceList = new List <int>();
                    foreach (GridDataItem item in _radGridPaymentHistory.SelectedItems)
                    {
                        selectedInvoiceList.Add((int)item.GetDataKeyValue("PaymentId"));
                    }

                    RunClientScript("ShowReportPop('" + String.Join(", ", selectedInvoiceList.ToArray()) + "', '" + (int)CConstValue.Report.DetailPaymentAgency + "' );");
                }
                break;

            case "Student Detail Reciept":
                if (_radGridPaymentHistory.SelectedValue != null)
                {
                    var selectedInvoiceList = new List <int>();
                    foreach (GridDataItem item in _radGridPaymentHistory.SelectedItems)
                    {
                        selectedInvoiceList.Add((int)item.GetDataKeyValue("PaymentId"));
                    }

                    RunClientScript("ShowReportPop('" + String.Join(", ", selectedInvoiceList.ToArray()) + "', '" + (int)CConstValue.Report.DetailPaymentStudent + "' );");
                }

                //if (_radGridPaymentHistory.SelectedValue != null)
                //{
                //    RunClientScript("ShowReportPop('" + _radGridPaymentHistory.SelectedValue + "', '" + (int)CConstValue.Report.DetailPaymentStudent + "');");
                //}
                break;

            case "Payment Reverse":
                if (_radGridPaymentHistory.SelectedValue != null)
                {
                    var payment = new CPayment().Get(Convert.ToInt32(_radGridPaymentHistory.SelectedValue));
                    if (payment.Amount > 0)
                    {
                        var cNewPayment = new CPayment();
                        var newPayment  = new Erp2016.Lib.Payment();
                        CGlobal.Copy(payment, newPayment);
                        newPayment.Amount           *= -1;
                        newPayment.OriginalPaymentId = payment.PaymentId;

                        cNewPayment.Add(newPayment);

                        RadGridPayment.Rebind();
                    }
                    else
                    {
                        ShowMessage("Negative price can't reverse");
                    }
                }
                break;
            }
        }