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);
        }
        public AdjustDebitNoteForm GetDataIntoModel()
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

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

            PQForm.AdjustDebitNoteDetails = new List <AdjustDebitNoteDetailsEntity>();
            AdjustDebitNoteEntity model = new AdjustDebitNoteEntity();

            //  this.ID = pqf.AdjustDebitNote.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;
            model.DebitNoteNo           = this.DebitNoteNo;
            model.AdjustDebitNoteNumber = this.AdjustDebitNoteNumber;
            model.AdjustDebitNoteDate   = DateTime.ParseExact(this.AdjustDebitNoteDateStr, oData.DateFormat, null);
            if (this.IsChequeTrue == true)
            {
                model.IsCheque = true;
            }
            else
            {
                model.IsCheque = false;
            }

            PQForm.AdjustDebitNote = model;

            foreach (var item in PQDetailsEntity.Where(e => !(string.IsNullOrEmpty(e.AmountAdjustedStr))))
            {
                AdjustDebitNoteDetailsEntity pqEntity = new AdjustDebitNoteDetailsEntity();

                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.PaymentDueDate = DateTime.ParseExact(item.PaymentDueDateStr, "dd'/'MM'/'yy", CultureInfo.InvariantCulture);
                //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);
                pqEntity.CheckAmountAdjusted = item.CheckAmountAdjusted;

                PQForm.AdjustDebitNoteDetails.Add(pqEntity);
            }
            return(PQForm);
        }
        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);
        }
        public bool CanSave(object param)
        {
            string date = this.DateFormat as string;
            var    c    = CompanyD.GetCompanyDetails().Comp_year_start_date;

            if ((SelectedSupplierID != null || SelectedSupplierID != 0) &&
                (SelectedAccountID != null || SelectedAccountID != 0) &&
                !(string.IsNullOrEmpty(AmountStr)) && !(string.IsNullOrEmpty(CashChequeNo)) &&
                Date != null)
            {
                if (DateStr != null)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(DateStr) && !string.IsNullOrWhiteSpace(DateStr))
                        {
                            //item.StartDate = item.StartDate.Replace('.', '/');
                            //item.StartDate = item.StartDate.Replace('-', '/');
                            //item.EndDate = item.EndDate.Replace('.', '/');
                            //item.EndDate = item.EndDate.Replace('-', '/');
                            var Start = (DateTime.ParseExact(DateStr, date, CultureInfo.InvariantCulture));
                            this.DateErrors = "";
                            //var End = (DateTime.ParseExact(item.EndDate, date, CultureInfo.InvariantCulture));
                            if (Start < c)
                            {
                                this.DateErrors = "Date should be greater than Start Financial year";
                                return(false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        this.DateErrors = "Please enter the date in " + date + " format!";
                        return(false);
                    }
                    if (PQDetailsEntity == null)
                    {
                        return(false);
                    }
                    else
                    {
                        foreach (var item in PQDetailsEntity.Where(e => Convert.ToDecimal(e.AmountAdjustedStr) != 0))
                        {
                            RefundFromSupplierDetailsEntity pqEntity = new RefundFromSupplierDetailsEntity();
                            var amtDue = pqEntity.AmountDue = Convert.ToDecimal(item.AmountDueStr);

                            var amtadjusted = pqEntity.AmountAdjusted = Convert.ToDecimal(item.AmountAdjustedStr);
                            //if (amtadjusted <= amtDue)
                            //{
                            //    this.DateErrors = "Adjusted Amount Can't exceed with Amount Due";
                            //    return false;
                            //}
                            if (amtadjusted < 0)
                            {
                                this.DateErrors = "amount adjusted Can't be negative";
                                return(false);
                            }
                            else if (amtadjusted > amtDue)
                            {
                                this.DateErrors = "Amount adjusted must not exceed amount due";
                                return(false);
                            }
                        }
                        return(true);
                    }
                    return(true);
                }

                return(true);
            }



            else
            {
                return(false);
            }
        }