Example #1
0
 private void GetPSData(object param)
 {
     if (SelectedSupplierID != null && SelectedSupplierID != 0)
     {
         RefundFromSupplierForm pqf = psRepository.GetNewPS(SelectedSupplierID);
         GetModelData(pqf);
     }
 }
Example #2
0
        private void GetRefundFromSupplierDetails(string cashChequeNo)
        {
            this.ListSuppliers = supplierRepository.GetAllSupplier().ToList();
            IsNew = false;
            RefundFromSupplierForm pqf = psRepository.GetRefundFromSupplierDetails(cashChequeNo);

            GetModelData(pqf);
        }
        public int UpdateRefundFromSupplier(RefundFromSupplierForm psForm)
        {
            try
            {
                using (SDNPurchasingDBEntities entities = new SDNPurchasingDBEntities())
                {
                    foreach (var item in psForm.RefundFromSupplierDetails)
                    {
                        CashAndBankTransaction obj = entities.CashAndBankTransactions.Where(e => e.Cash_Cheque_No == psForm.RefundFromSupplier.CashChequeNo &&
                                                                                            e.SO_CN_PO_DN_No == item.PurchaseNo).SingleOrDefault();
                        if (obj != null)
                        {
                            obj.Acc_Id           = psForm.RefundFromSupplier.AccountId;
                            obj.Amount           = psForm.RefundFromSupplier.Amount;
                            obj.Cash_Cheque_No   = psForm.RefundFromSupplier.CashChequeNo;
                            obj.Cash_Cheque_Date = psForm.RefundFromSupplier.Date;
                            obj.Remarks          = psForm.RefundFromSupplier.Remarks;

                            obj.Is_Cheque = psForm.RefundFromSupplier.IsCheque;

                            //saving details entity
                            obj.SO_CN_PO_DN_No   = item.PurchaseNo;
                            obj.SO_CN_PO_DN_Date = item.PurchaseDate;
                            obj.SO_CN_PO_DN_Amt  = item.PurchaseAmount;
                            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.PurchaseAmount)
                            {
                                DebitNote     dn    = entities.DebitNotes.Where(e => e.DN_No == item.PurchaseNo).SingleOrDefault();
                                PurchaseOrder order = entities.PurchaseOrders.Where(e => e.PO_No == item.PurchaseNo).SingleOrDefault();
                                if (dn != null)
                                {
                                    dn.DN_Status = Convert.ToByte(DN_Status.Refunded);
                                    entities.SaveChanges();
                                }
                                else if (order != null)
                                {
                                    order.PO_Status = Convert.ToByte(PO_Status.Refunded);
                                    entities.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(psForm.RefundFromSupplier.ID);
        }
        public RefundFromSupplierForm GetRefundFromSupplierDetails(string cashChequeNo)
        {
            string str = Convert.ToString(Convert.ToByte(CashBankTransactionType.RefundFromSupplier));
            RefundFromSupplierForm pqf = new RefundFromSupplierForm();

            try
            {
                using (SDNPurchasingDBEntities entities = new SDNPurchasingDBEntities())
                {
                    var pq = (from pqs in entities.CashAndBankTransactions
                              where pqs.Cash_Cheque_No == cashChequeNo &&
                              pqs.Type == str
                              select new RefundFromSupplierEntity
                    {
                        ID = pqs.ID,
                        SupplierID = 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.RefundFromSupplier = pq;
                    }


                    var pqd = (from pqs in entities.CashAndBankTransactions
                               where pqs.Cash_Cheque_No == cashChequeNo &&
                               pqs.Type == str
                               select new RefundFromSupplierDetailsEntity
                    {
                        PurchaseNo = pqs.SO_CN_PO_DN_No,
                        PurchaseDate = pqs.SO_CN_PO_DN_Date,
                        PurchaseAmount = pqs.SO_CN_PO_DN_Amt,
                        AmountDue = pqs.Amt_Due,
                        Discount = pqs.Discount,
                        AmountAdjusted = pqs.Amt_Refunded
                    }).ToList <RefundFromSupplierDetailsEntity>();

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

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void GetModelData(RefundFromSupplierForm pqf)
        {
            if (IsNew == false)
            {
                //this.ID = pqf.RefundFromSupplier.ID;
                this.SelectedSupplierID = pqf.RefundFromSupplier.SupplierID;
                this.SelectedAccountID  = pqf.RefundFromSupplier.AccountId;

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

            var result = pqf.RefundFromSupplierDetails.OrderByDescending(e => e.CreatedDate).GroupBy(e => e.PurchaseNo).Select(e => e.First()).ToList();

            this.PQDetailsEntity = new ObservableCollection <CollectAmountDataGridViewModel>();
            foreach (var item in result)
            {
                CollectAmountDataGridViewModel pqEntity = new CollectAmountDataGridViewModel();
                pqEntity.PurchaseNo        = item.PurchaseNo;
                pqEntity.PurchaseDate      = item.PurchaseDate;
                pqEntity.PurchaseDateStr   = changedateformat(item.PurchaseDate);
                pqEntity.PurchaseAmountStr = Convert.ToString(item.PurchaseAmount);
                pqEntity.PurchaseAmount    = item.PurchaseAmount;
                pqEntity.PaymentDueDate    = item.PaymentDueDate;
                pqEntity.PaymentDueDateStr = changedateformat(item.PaymentDueDate);
                pqEntity.AmountDue         = Math.Abs(decimal.Parse(Convert.ToString(item.AmountDue)));
                pqEntity.AmountDueStr      = Convert.ToString(Math.Abs(decimal.Parse(Convert.ToString(item.AmountDue))));
                pqEntity.AmountAdjusted    = item.AmountAdjusted;
                pqEntity.AmountAdjustedStr = Convert.ToString(item.AmountAdjusted);
                pqEntity.Discount          = item.Discount;
                pqEntity.DiscountStr       = Convert.ToString(item.Discount);

                PQDetailsEntity.Add(pqEntity);
                OnPropertyChanged("PQDetailsEntity");
            }

            TotalSalesAmount = Convert.ToString(PQDetailsEntity.Sum(e => e.PurchaseAmount));
            TotalAmountDue   = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountDue));
            TotalAmountPaid  = Convert.ToString(PQDetailsEntity.Sum(e => e.AmountAdjusted));

            PQDetailsEntityLst = PQDetailsEntity;
        }
        public RefundFromSupplierForm GetDataIntoModel()
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

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

            PQForm.RefundFromSupplierDetails = new List <RefundFromSupplierDetailsEntity>();
            RefundFromSupplierEntity model = new RefundFromSupplierEntity();

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

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

                pqEntity.PurchaseNo     = item.PurchaseNo;
                pqEntity.PurchaseDate   = item.PurchaseDate;
                pqEntity.PurchaseAmount = Convert.ToDecimal(item.PurchaseAmountStr);
                //item.PurchaseAmount=pqEntity.PurchaseAmount;
                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.RefundFromSupplierDetails.Add(pqEntity);
            }
            return(PQForm);
        }
        private void GetRefundFromSupplierDetails(string cashChequeNo)
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

            oData = purchaseRepository.GetOptionSettings();
            this.ListSuppliers = supplierRepository.GetAllSupplier().ToList();
            IsNew = false;
            RefundFromSupplierForm pqf = psRepository.GetRefundFromSupplierDetails(cashChequeNo);
            DateTime Dateinstr         = (DateTime)pqf.RefundFromSupplier.Date;

            this.DateStr = Dateinstr.ToString(oData.DateFormat);
            GetModelData(pqf);
        }
Example #8
0
        public RefundFromSupplierForm GetDataIntoModel()
        {
            RefundFromSupplierForm PQForm = new RefundFromSupplierForm();

            PQForm.RefundFromSupplierDetails = new List <RefundFromSupplierDetailsEntity>();
            RefundFromSupplierEntity model = new RefundFromSupplierEntity();

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

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

                pqEntity.PurchaseNo     = item.PurchaseNo;
                pqEntity.PurchaseDate   = item.PurchaseDate;
                pqEntity.PurchaseAmount = Convert.ToDecimal(item.PurchaseAmountStr);
                //item.PurchaseAmount=pqEntity.PurchaseAmount;
                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.RefundFromSupplierDetails.Add(pqEntity);
            }
            return(PQForm);
        }
Example #9
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;
                RefundFromSupplierForm PSForm = GetDataIntoModel();
                string msg = ValidateRefundFromSupplier();
                if (msg != string.Empty)
                {
                    PSErrors             = msg;
                    Mouse.OverrideCursor = null;
                    return;
                }

                PSErrors = string.Empty;

                if (PSForm != null)
                {
                    if (IsNew == true)
                    {
                        int i = psRepository.SaveRefundFromSupplier(PSForm);
                        IsSupplierEnabled = false;
                        IsTextBoxReadOnly = true;
                        IsNew             = false;
                    }
                    else
                    {
                        int i = psRepository.UpdateRefundFromSupplier(PSForm);
                        IsNew             = false;
                        IsSupplierEnabled = false;
                        IsTextBoxReadOnly = true;
                    }

                    Mouse.OverrideCursor = null;
                }
            }
        }
        public RefundFromSupplierForm GetNewPS(int?SupplierID)
        {
            RefundFromSupplierForm pqf = new RefundFromSupplierForm();

            try
            {
                using (SDNPurchasingDBEntities entities = new SDNPurchasingDBEntities())
                {
                    var pqd = entities.Database.SqlQuery <RefundFromSupplierDetailsEntity>("PRC_GetPurchaseDataForRefundFromSuppliers @SupplierID={0}", SupplierID).ToList();

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

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int UpdateRefundFromSupplier(RefundFromSupplierForm psForm)
        {
            IRefundFromSupplierBL psBL = new RefundFromSupplierBL();

            return(psBL.UpdateRefundFromSupplier(psForm));
        }
Example #12
0
        public int SaveRefundFromSupplier(RefundFromSupplierForm psForm)
        {
            IRefundFromSupplierDAL psDAL = new RefundFromSupplierDAL();

            return(psDAL.SaveRefundFromSupplier(psForm));
        }