public PaymentFromCustomerForm GetDataIntoModel() { OptionsEntity oData = new OptionsEntity(); ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository(); oData = purchaseRepository.GetOptionSettings(); PaymentFromCustomerForm PQForm = new PaymentFromCustomerForm(); PQForm.PaymentFromCustomerDetails = new List <PaymentFromCustomerDetailsEntity>(); PaymentFromCustomerEntity model = new PaymentFromCustomerEntity(); // this.ID = pqf.PaymentFromCustomer.ID; model.CustomerID = this.SelectedCustomerID; model.AccountId = this.SelectedAccountID; //model.DateStr = this.DateStr; model.Date = DateTime.ParseExact(this.DateStr, oData.DateFormat, null); model.AmountStr = this.AmountStr; model.Amount = Convert.ToDecimal(this.AmountStr); model.IsCheque = this.IsCheque; model.CashChequeNo = this.CashChequeNo; model.Remarks = this.Remarks; if (this.IsChequeTrue == true) { model.IsCheque = true; } else { model.IsCheque = false; } PQForm.PaymentFromCustomer = model; foreach (var item in PQDetailsEntity.Where(e => Convert.ToDecimal(e.AmountAdjustedStr) != 0)) { PaymentFromCustomerDetailsEntity pqEntity = new PaymentFromCustomerDetailsEntity(); pqEntity.SalesNo = item.SalesNo; pqEntity.SalesDate = item.SalesDate; pqEntity.SalesAmount = Convert.ToDecimal(item.SalesAmountStr); //item.SalesAmount=pqEntity.SalesAmount; if (item.PaymentDueDateStr != string.Empty) { // pqEntity.PaymentDueDate = Convert.ToDateTime(item.PaymentDueDateStr); pqEntity.PaymentDueDate = Utility.SimpleDateTime(item.PaymentDueDateStr); //Sunil Sharma } else { pqEntity.PaymentDueDate = null; } //pqEntity.AmountDueStr = Convert.ToString(item.AmountDue); pqEntity.AmountDue = Convert.ToDecimal(item.AmountDueStr); // pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted); pqEntity.AmountAdjusted = Convert.ToDecimal(item.AmountAdjustedStr); pqEntity.Discount = Convert.ToDecimal(item.DiscountStr); PQForm.PaymentFromCustomerDetails.Add(pqEntity); } return(PQForm); }
private void GetPSData(object param) { if (SelectedCustomerID != null && SelectedCustomerID != 0) { PaymentFromCustomerForm pqf = psRepository.GetNewPS(SelectedCustomerID); GetModelData(pqf); } }
private void GetPaymentFromCustomerDetails(string cashChequeNo) { this.ListCustomers = CustomerRepository.GetAllCustomers().ToList(); IsNew = false; PaymentFromCustomerForm pqf = psRepository.GetPaymentFromCustomerDetails(cashChequeNo); GetModelData(pqf); }
private void GetModelData(PaymentFromCustomerForm pqf) { if (IsNew == false) { // this.ID = pqf.PaymentFromCustomer.ID; this.SelectedCustomerID = pqf.PaymentFromCustomer.CustomerID; this.SelectedAccountID = pqf.PaymentFromCustomer.AccountId; this.AmountStr = pqf.PaymentFromCustomer.AmountStr; this.IsCheque = pqf.PaymentFromCustomer.IsCheque; this.CashChequeNo = pqf.PaymentFromCustomer.CashChequeNo; this.Remarks = pqf.PaymentFromCustomer.Remarks; if (IsCheque == true) { IsChequeTrue = true; IsChequeFalse = false; } else { IsChequeFalse = true; IsChequeTrue = false; } } var result = pqf.PaymentFromCustomerDetails.OrderByDescending(e => e.CreatedDate).GroupBy(e => e.SalesNo).Select(e => e.First()).ToList(); this.PQDetailsEntity = new ObservableCollection <CollectSalesAmountDataGridViewModel>(); foreach (var item in result) { CollectSalesAmountDataGridViewModel pqEntity = new CollectSalesAmountDataGridViewModel(); pqEntity.SalesNo = item.SalesNo; pqEntity.SalesDate = item.SalesDate; pqEntity.SalesDateStr = changedateformat(item.SalesDate); pqEntity.SalesAmountStr = Convert.ToString(item.SalesAmount); pqEntity.SalesAmount = item.SalesAmount; pqEntity.PaymentDueDate = item.PaymentDueDate; pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate); pqEntity.AmountDue = item.AmountDue; pqEntity.AmountDueStr = Convert.ToString(item.AmountDue); pqEntity.AmountAdjusted = item.AmountAdjusted; pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted); pqEntity.Discount = item.Discount; PQDetailsEntity.Add(pqEntity); OnPropertyChanged("PQDetailsEntity"); } TotalSalesAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.SalesAmount)); TotalAmountDue = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountDue)); TotalAmountPaid = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted)); PQDetailsEntityLst = PQDetailsEntity; }
public PaymentFromCustomerForm GetPaymentFromCustomerDetails(string cashChequeNo) { PaymentFromCustomerForm pqf = new PaymentFromCustomerForm(); try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { var pq = (from pqs in entities.CashAndBankTransactions where pqs.Cash_Cheque_No == cashChequeNo select new PaymentFromCustomerEntity { ID = pqs.ID, CustomerID = pqs.Cus_Sup_Id, Amount = pqs.Amount, AccountId = pqs.Acc_Id, Remarks = pqs.Remarks, Date = pqs.Cash_Cheque_Date, IsCheque = pqs.Is_Cheque, CashChequeNo = pqs.Cash_Cheque_No, }).FirstOrDefault(); if (pq != null) { pq.AmountStr = Convert.ToString(pq.Amount); pqf.PaymentFromCustomer = pq; } var pqd = (from pqs in entities.CashAndBankTransactions where pqs.Cash_Cheque_No == cashChequeNo select new PaymentFromCustomerDetailsEntity { SalesNo = pqs.SO_CN_PO_DN_No, SalesDate = pqs.SO_CN_PO_DN_Date, SalesAmount = pqs.SO_CN_PO_DN_Amt, AmountDue = pqs.Amt_Due, Discount = pqs.Discount, AmountAdjusted = pqs.Amt_Refunded }).ToList <PaymentFromCustomerDetailsEntity>(); if (pqd != null) { pqf.PaymentFromCustomerDetails = pqd; } return(pqf); } } catch (Exception ex) { throw ex; } }
public PaymentFromCustomerForm GetDataIntoModel() { PaymentFromCustomerForm PQForm = new PaymentFromCustomerForm(); PQForm.PaymentFromCustomerDetails = new List <PaymentFromCustomerDetailsEntity>(); PaymentFromCustomerEntity model = new PaymentFromCustomerEntity(); // this.ID = pqf.PaymentFromCustomer.ID; model.CustomerID = this.SelectedCustomerID; model.AccountId = this.SelectedAccountID; model.Date = this.Date; model.AmountStr = this.AmountStr; model.Amount = Convert.ToDecimal(this.AmountStr); model.IsCheque = this.IsCheque; model.CashChequeNo = this.CashChequeNo; model.Remarks = this.Remarks; if (this.IsChequeTrue == true) { model.IsCheque = true; } else { model.IsCheque = false; } PQForm.PaymentFromCustomer = model; foreach (var item in PQDetailsEntity) { PaymentFromCustomerDetailsEntity pqEntity = new PaymentFromCustomerDetailsEntity(); pqEntity.SalesNo = item.SalesNo; pqEntity.SalesDate = item.SalesDate; pqEntity.SalesAmount = Convert.ToDecimal(item.SalesAmountStr); //item.SalesAmount=pqEntity.SalesAmount; if (item.PaymentDueDateStr != string.Empty) { pqEntity.PaymentDueDate = Convert.ToDateTime(item.PaymentDueDateStr); } else { pqEntity.PaymentDueDate = null; } //pqEntity.AmountDueStr = Convert.ToString(item.AmountDue); pqEntity.AmountDue = Convert.ToDecimal(item.AmountDueStr); // pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted); pqEntity.AmountAdjusted = Convert.ToDecimal(item.AmountAdjustedStr); pqEntity.Discount = Convert.ToDecimal(item.DiscountStr); PQForm.PaymentFromCustomerDetails.Add(pqEntity); } return(PQForm); }
private void GetPaymentFromCustomerDetails(string cashChequeNo) { OptionsEntity oData = new OptionsEntity(); ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository(); oData = purchaseRepository.GetOptionSettings(); this.ListCustomers = CustomerRepository.GetCustomerList().ToList(); IsNew = false; PaymentFromCustomerForm pqf = psRepository.GetPaymentFromCustomerDetails(cashChequeNo); if (pqf.PaymentFromCustomer != null) { DateTime Dateinstr = (DateTime)pqf.PaymentFromCustomer.Date; this.DateStr = Dateinstr.ToString(oData.DateFormat); GetModelData(pqf); } else { } }
void OnSavePS(object param) { MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to save changes?", "Save Confirmation", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { Mouse.OverrideCursor = Cursors.Wait; PaymentFromCustomerForm PSForm = GetDataIntoModel(); string msg = ValidatePaymentFromCustomer(); if (msg != string.Empty) { PSErrors = msg; Mouse.OverrideCursor = null; return; } PSErrors = string.Empty; if (PSForm != null) { if (IsNew == true) { int i = psRepository.SavePaymentFromCustomer(PSForm); IsCustomerEnabled = false; IsTextBoxReadOnly = true; IsNew = false; } else { int i = psRepository.UpdatePaymentFromCustomer(PSForm); IsCustomerEnabled = false; IsTextBoxReadOnly = true; IsNew = false; } Mouse.OverrideCursor = null; } } }
public PaymentFromCustomerForm GetNewPS(int?CustomerID) { PaymentFromCustomerForm pqf = new PaymentFromCustomerForm(); try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { var pqd = entities.Database.SqlQuery <PaymentFromCustomerDetailsEntity>("PRC_GetSalesDataForPaymentFromCustomers @CustomerID={0}", CustomerID).ToList(); if (pqd != null) { pqf.PaymentFromCustomerDetails = pqd; } return(pqf); } } catch (Exception ex) { throw ex; } }
public int SavePaymentFromCustomer(PaymentFromCustomerForm psForm) { int autoId = 0; try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { foreach (var item in psForm.PaymentFromCustomerDetails) { //CashAndBankTransaction obj = entities.CashAndBankTransactions.Where(e => e.SO_CN_PO_DN_No == item.SalesNo).SingleOrDefault(); //if(obj!=null) //{ // // obj.Acc_Id = psForm.PaymentToSupplier.AccountId; // obj.Amount = psForm.PaymentToSupplier.Amount; // //saving details entity // obj.SO_CN_PO_DN_No = item.SalesNo; // obj.SO_CN_PO_DN_Date = item.SalesDate; // obj.SO_CN_PO_DN_Amt = item.SalesAmount; // obj.Amt_Due = item.AmountDue; // obj.Amt_Refunded = item.AmountAdjusted; // obj.Discount = item.Discount; // obj.UpdatedBy = 0; // obj.UpdatedDate = DateTime.Now.Date; // entities.SaveChanges(); //} //else //{ CashAndBankTransaction obj = new CashAndBankTransaction(); obj.Cus_Sup_Id = psForm.PaymentFromCustomer.CustomerID; obj.Acc_Id = psForm.PaymentFromCustomer.AccountId; obj.Amount = psForm.PaymentFromCustomer.Amount; obj.Cash_Cheque_No = psForm.PaymentFromCustomer.CashChequeNo; obj.Cash_Cheque_Date = psForm.PaymentFromCustomer.Date; obj.Remarks = psForm.PaymentFromCustomer.Remarks; obj.Type = "C"; obj.Is_Cheque = psForm.PaymentFromCustomer.IsCheque; //saving details entity obj.SO_CN_PO_DN_No = item.SalesNo; obj.SO_CN_PO_DN_Date = item.SalesDate; obj.SO_CN_PO_DN_Amt = item.SalesAmount; obj.Amt_Due = item.AmountDue - item.AmountAdjusted; obj.Amt_Refunded = item.AmountAdjusted; obj.Discount = item.Discount; obj.UpdatedBy = 0; obj.UpdatedDate = DateTime.Now.Date; entities.CashAndBankTransactions.Add(obj); entities.SaveChanges(); SalesInvoice invoice = entities.SalesInvoices.Where(e => e.SI_No == item.SalesNo).FirstOrDefault(); SalesOrder order = entities.SalesOrders.Where(e => e.SO_No == item.SalesNo).FirstOrDefault(); if (invoice != null) { if (item.AmountAdjusted == item.SalesAmount) { invoice.SI_Status = Convert.ToByte(PI_Status.Paid); entities.SaveChanges(); } else { invoice.SI_Status = Convert.ToByte(PI_Status.UnPaid); entities.SaveChanges(); } } else if (order != null) { order.SO_Status = Convert.ToByte(PO_Status.Collected); entities.SaveChanges(); } //} } } } catch (Exception ex) { throw ex; } return(autoId); }
public int SavePaymentFromCustomer(PaymentFromCustomerForm psForm) { IPaymentFromCustomersBL psBL = new PaymentFromCustomersBL(); return(psBL.SavePaymentToSupplier(psForm)); }
public int UpdatePaymentToSupplier(PaymentFromCustomerForm psForm) { IPaymentFromCustomersDAL psDAL = new PaymentFromCustomersDAL(); return(psDAL.UpdatePaymentToSupplier(psForm)); }