Ejemplo n.º 1
0
        private void GetRefundToCustomerDetails(string cashChequeNo)
        {
            IsNew = false;
            RefundToCustomerForm pqf = psRepository.GetRefundToCustomerDetails(cashChequeNo);

            GetModelData(pqf);
        }
Ejemplo n.º 2
0
 private void GetPSData(object param)
 {
     if (SelectedCustomerID != null && SelectedCustomerID != 0)
     {
         RefundToCustomerForm pqf = psRepository.GetNewPS(SelectedCustomerID);
         GetModelData(pqf);
     }
 }
Ejemplo n.º 3
0
        public int UpdateRefundToCustomer(RefundToCustomerForm psForm)
        {
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    foreach (var item in psForm.RefundToCustomerDetails)
                    {
                        CashAndBankTransaction obj = entities.CashAndBankTransactions.Where(e => e.Cash_Cheque_No == psForm.RefundToCustomer.CashChequeNo &&
                                                                                            e.SO_CN_PO_DN_No == item.SalesNo).SingleOrDefault();
                        if (obj != null)
                        {
                            obj.Acc_Id           = psForm.RefundToCustomer.AccountId;
                            obj.Amount           = psForm.RefundToCustomer.Amount;
                            obj.Cash_Cheque_No   = psForm.RefundToCustomer.CashChequeNo;
                            obj.Cash_Cheque_Date = psForm.RefundToCustomer.Date;
                            obj.Remarks          = psForm.RefundToCustomer.Remarks;

                            obj.Is_Cheque = psForm.RefundToCustomer.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          = obj.Amt_Due = item.AmountDue - item.AmountAdjusted;
                            obj.Amt_Refunded     = item.AmountAdjusted;
                            obj.Discount         = item.Discount;

                            obj.UpdatedBy   = 0;
                            obj.UpdatedDate = DateTime.Now;
                            entities.SaveChanges();

                            if (item.AmountDue == 0 && item.AmountAdjusted == item.SalesAmount)
                            {
                                CreditNote dn    = entities.CreditNotes.Where(e => e.CN_No == item.SalesNo).SingleOrDefault();
                                SalesOrder order = entities.SalesOrders.Where(e => e.SO_No == item.SalesNo).SingleOrDefault();
                                if (dn != null)
                                {
                                    dn.CN_Status = Convert.ToByte(DN_Status.Refunded);
                                    entities.SaveChanges();
                                }
                                else if (order != null)
                                {
                                    order.SO_Status = Convert.ToByte(PO_Status.Refunded);
                                    entities.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(psForm.RefundToCustomer.ID);
        }
Ejemplo n.º 4
0
        public RefundToCustomerForm GetRefundToCustomerDetails(string cashChequeNo)
        {
            string str = Convert.ToString(Convert.ToByte(CashBankTransactionType.RefundToCustomer));
            RefundToCustomerForm pqf = new RefundToCustomerForm();

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pq = (from pqs in entities.CashAndBankTransactions
                              where pqs.Cash_Cheque_No == cashChequeNo &&
                              pqs.Type == str
                              select new RefundToCustomerEntity
                    {
                        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.RefundToCustomer = pq;
                    }


                    var pqd = (from pqs in entities.CashAndBankTransactions
                               where pqs.Cash_Cheque_No == cashChequeNo &&
                               pqs.Type == str
                               select new RefundToCustomerDetailsEntity
                    {
                        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 <RefundToCustomerDetailsEntity>();

                    if (pqd != null)
                    {
                        pqf.RefundToCustomerDetails = pqd;
                    }

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        public RefundToCustomerForm GetDataIntoModel()
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

            oData = purchaseRepository.GetOptionSettings();
            RefundToCustomerForm PQForm = new RefundToCustomerForm();

            PQForm.RefundToCustomerDetails = new List <RefundToCustomerDetailsEntity>();
            RefundToCustomerEntity model = new RefundToCustomerEntity();

            //  this.ID = pqf.RefundToCustomer.ID;
            model.CustomerID   = this.SelectedCustomerID;
            model.AccountId    = this.SelectedAccountID;
            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.RefundToCustomer = model;

            foreach (var item in PQDetailsEntity.Where(e => Convert.ToDecimal(e.AmountAdjustedStr) != 0))
            {
                RefundToCustomerDetailsEntity pqEntity = new RefundToCustomerDetailsEntity();

                pqEntity.SalesNo     = item.SalesNo;
                pqEntity.SalesDate   = item.SalesDate;
                pqEntity.SalesAmount = Convert.ToDecimal(item.SalesAmountStr);

                //pqEntity.PaymentDueDate = Convert.ToDateTime(item.PaymentDueDateStr);
                pqEntity.PaymentDueDate = Utility.SimpleDateTime(item.PaymentDueDateStr);//Sunil Sharma
                //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.RefundToCustomerDetails.Add(pqEntity);
            }
            return(PQForm);
        }
Ejemplo n.º 6
0
        private void GetRefundToCustomerDetails(string cashChequeNo)
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

            oData = purchaseRepository.GetOptionSettings();
            IsNew = false;
            RefundToCustomerForm pqf       = psRepository.GetRefundToCustomerDetails(cashChequeNo);
            DateTime             Dateinstr = (DateTime)pqf.RefundToCustomer.Date;

            this.DateStr = Dateinstr.ToString(oData.DateFormat);
            GetModelData(pqf);
        }
Ejemplo n.º 7
0
        private void GetModelData(RefundToCustomerForm pqf)
        {
            if (IsNew == false)
            {
                this.ID = pqf.RefundToCustomer.ID;
                this.SelectedCustomerID = pqf.RefundToCustomer.CustomerID;
                this.SelectedAccountID  = pqf.RefundToCustomer.AccountId;

                this.AmountStr = pqf.RefundToCustomer.AmountStr;
                this.IsCheque  = pqf.RefundToCustomer.IsCheque;
                if (IsCheque == true)
                {
                    IsChequeTrue = true;
                }
                else
                {
                    IsChequeFalse = true;
                }
                this.CashChequeNo = pqf.RefundToCustomer.CashChequeNo;
                this.Remarks      = pqf.RefundToCustomer.Remarks;
            }

            this.PQDetailsEntity = new ObservableCollection <CollectSalesAmountDataGridViewModel>();
            foreach (var item in pqf.RefundToCustomerDetails)
            {
                CollectSalesAmountDataGridViewModel pqEntity = new CollectSalesAmountDataGridViewModel();
                pqEntity.SalesNo      = item.SalesNo;
                pqEntity.SalesDate    = item.SalesDate;
                pqEntity.SalesDateStr = changedateformat(item.SalesDate);

                pqEntity.SalesAmount       = Math.Abs(decimal.Parse(item.SalesAmount.ToString()));
                pqEntity.SalesAmountStr    = Convert.ToString(pqEntity.SalesAmount);
                pqEntity.PaymentDueDate    = item.PaymentDueDate;
                pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate);
                pqEntity.AmountDue         = Math.Abs(decimal.Parse(item.AmountDue.ToString()));
                pqEntity.AmountDueStr      = Convert.ToString(pqEntity.AmountDue);
                pqEntity.AmountAdjusted    = Math.Abs(decimal.Parse(item.AmountAdjusted.ToString()));
                pqEntity.AmountAdjustedStr = Convert.ToString(pqEntity.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;
        }
Ejemplo n.º 8
0
        public RefundToCustomerForm GetDataIntoModel()
        {
            RefundToCustomerForm PQForm = new RefundToCustomerForm();

            PQForm.RefundToCustomerDetails = new List <RefundToCustomerDetailsEntity>();
            RefundToCustomerEntity model = new RefundToCustomerEntity();

            //  this.ID = pqf.RefundToCustomer.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.RefundToCustomer = model;

            foreach (var item in PQDetailsEntity)
            {
                RefundToCustomerDetailsEntity pqEntity = new RefundToCustomerDetailsEntity();

                pqEntity.SalesNo     = item.SalesNo;
                pqEntity.SalesDate   = item.SalesDate;
                pqEntity.SalesAmount = Convert.ToDecimal(item.SalesAmountStr);
                //item.SalesAmount=pqEntity.SalesAmount;
                pqEntity.PaymentDueDate = Convert.ToDateTime(item.PaymentDueDateStr);
                //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.RefundToCustomerDetails.Add(pqEntity);
            }
            return(PQForm);
        }
Ejemplo n.º 9
0
        public RefundToCustomerForm GetNewPS(int?CustomerID)
        {
            RefundToCustomerForm pqf = new RefundToCustomerForm();

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pqd = entities.Database.SqlQuery <RefundToCustomerDetailsEntity>("SRC_GetSalesDataForRefundToCustomers @CustomerID={0}", CustomerID).ToList();

                    if (pqd != null)
                    {
                        pqf.RefundToCustomerDetails = pqd;
                    }

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 10
0
        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;
                RefundToCustomerForm PSForm = GetDataIntoModel();
                string msg = ValidateRefundToCustomer();
                if (msg != string.Empty)
                {
                    PSErrors             = msg;
                    Mouse.OverrideCursor = null;
                    return;
                }

                PSErrors = string.Empty;


                if (PSForm != null)
                {
                    if (IsNew == true)
                    {
                        int i = psRepository.SaveRefundToCustomer(PSForm);
                        IsCustomerEnabled = false;
                        IsTextBoxReadOnly = true;
                    }
                    else
                    {
                        int i = psRepository.UpdateRefundToCustomer(PSForm);
                        IsCustomerEnabled = false;
                        IsTextBoxReadOnly = true;
                    }
                    Mouse.OverrideCursor = null;
                }
            }
        }
Ejemplo n.º 11
0
        public int SaveRefundToCustomer(RefundToCustomerForm psForm)
        {
            IRefundToCustomersBL psBL = new RefundToCustomersBL();

            return(psBL.SavePaymentToSupplier(psForm));
        }
        public int UpdatePaymentToSupplier(RefundToCustomerForm psForm)
        {
            IRefundToCustomersDAL psDAL = new RefundToCustomersDAL();

            return(psDAL.UpdateRefundToCustomer(psForm));
        }
Ejemplo n.º 13
0
        public int SaveRefundToCustomer(RefundToCustomerForm psForm)
        {
            int autoId = 0;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    foreach (var item in psForm.RefundToCustomerDetails)
                    {
                        CashAndBankTransaction obj = new CashAndBankTransaction();
                        obj.Cus_Sup_Id       = psForm.RefundToCustomer.CustomerID;
                        obj.Acc_Id           = psForm.RefundToCustomer.AccountId;
                        obj.Amount           = psForm.RefundToCustomer.Amount;
                        obj.Cash_Cheque_No   = psForm.RefundToCustomer.CashChequeNo;
                        obj.Cash_Cheque_Date = psForm.RefundToCustomer.Date;
                        obj.Remarks          = psForm.RefundToCustomer.Remarks;
                        obj.Type             = Convert.ToString(Convert.ToByte(CashBankTransactionType.RefundToCustomer));
                        //obj.Type = "C";
                        obj.Is_Cheque = psForm.RefundToCustomer.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_Due = item.AmountDue;
                        obj.Amt_Refunded = item.AmountAdjusted;
                        obj.Discount     = item.Discount;

                        obj.UpdatedBy   = 0;
                        obj.UpdatedDate = DateTime.Now;

                        entities.CashAndBankTransactions.Add(obj);
                        entities.SaveChanges();

                        if (item.AmountAdjusted == item.SalesAmount)
                        {
                            CreditNote dn    = entities.CreditNotes.Where(e => e.CN_No == item.SalesNo).SingleOrDefault();
                            SalesOrder order = entities.SalesOrders.Where(e => e.SO_No == item.SalesNo).SingleOrDefault();
                            if (dn != null)
                            {
                                dn.CN_Status = Convert.ToByte(DN_Status.Refunded);
                                entities.SaveChanges();
                            }
                            else if (order != null)
                            {
                                order.SO_Status = Convert.ToByte(PO_Status.Refunded);
                                entities.SaveChanges();
                            }
                        }

                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(autoId);
        }