Пример #1
0
 public bool Update(CreditMemoCreditHistory obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
Пример #2
0
        public int Add(CreditMemoCreditHistory obj)
        {
            try
            {
                obj.CreatedDate = DateTime.Now;

                _db.CreditMemoCreditHistories.InsertOnSubmit(obj);
                _db.SubmitChanges();
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                return(-1);
            }
            return(_db.CreditMemoCreditHistories.Max(x => x.CreditMemoCreditHistoryId));
        }
Пример #3
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");
            }
        }