Пример #1
0
        public Prq_BillPayment SetToModelObject(PrqBillPayment model)
        {
            Prq_BillPayment Entity = new Prq_BillPayment();

            Entity.PaymentDate       = DalCommon.SetDate(model.PaymentDate);// Convert.ToDateTime(Convert.ToDateTime(model.PaymentDate).ToString("dd/MM/yyyy"));
            Entity.SupplierID        = model.SupplierID;
            Entity.SupplierAddressID = model.SupplierAddressID;
            Entity.PaymentType       = model.PaymentType;
            Entity.PaymentMethod     = model.PaymentMethod;
            Entity.Currency          = model.Currency;
            Entity.PaymentDoc        = model.PaymentDoc;
            Entity.BillAmount        = model.BillAmount;
            Entity.VatPercentage     = model.VatPercentage;
            Entity.VatAmount         = model.VatAmount;
            Entity.DeductAmount      = model.DeductAmount;
            Entity.PaymentAmount     = model.PaymentAmount;
            Entity.Remarks           = model.Remarks;
            Entity.RecordStatus      = "NCF";
            Entity.PurchaseYear      = model.PurchaseYear;
            Entity.PaymentStatus     = true;
            Entity.SetOn             = DateTime.Now;
            Entity.SetBy             = model.SetBy;
            Entity.IPAddress         = string.Empty;

            return(Entity);
        }
Пример #2
0
        //public List<PrqBillPayment> GetBillPaymentListForSearch(string supplier)
        //{
        //    List<Prq_BillPayment> searchList = _context.Prq_BillPayment.Where(m => m.RecordStatus == "NCF").ToList(); //using table
        //    return searchList.Select(c => SetToBussinessObject(c)).ToList<PrqBillPayment>();
        //}

        public PrqBillPayment SetToBussinessObject(Prq_BillPayment Entity)
        {
            PrqBillPayment model = new PrqBillPayment();

            model.PaymentID         = Entity.PaymentID;
            model.PaymentDate       = Entity.PaymentDate.ToString("dd/MM/yyyy");
            model.SupplierID        = Entity.SupplierID;
            model.SupplierName      = _context.Sys_Supplier.Where(m => m.SupplierID == Entity.SupplierID).FirstOrDefault().SupplierName;
            model.SupplierCode      = _context.Sys_Supplier.Where(m => m.SupplierID == Entity.SupplierID).FirstOrDefault().SupplierCode;
            model.SupplierAddressID = Entity.SupplierAddressID;
            var abc =
                _context.Sys_SupplierAddress.Where(
                    q => q.SupplierID == Entity.SupplierID && q.IsActive.Equals(true) && q.IsDelete.Equals(false))
                .FirstOrDefault();

            if (abc != null)
            {
                model.Address = _context.Sys_SupplierAddress.Where(q => q.SupplierID == Entity.SupplierID && q.IsActive.Equals(true) && q.IsDelete.Equals(false)).FirstOrDefault().Address;
            }
            model.PaymentType     = Entity.PaymentType;
            model.PaymentTypeName = _context.Sys_PaymentType.Where(m => m.ID == Entity.PaymentType).FirstOrDefault().Name;
            model.PaymentMethod   = Entity.PaymentMethod;
            model.Currency        = Entity.Currency;
            model.PaymentDoc      = Entity.PaymentDoc;
            model.BillAmount      = Entity.BillAmount;
            model.VatPercentage   = Entity.VatPercentage;
            model.VatAmount       = Entity.VatAmount;
            model.DeductAmount    = Entity.DeductAmount;
            model.PaymentAmount   = Entity.PaymentAmount;
            model.Remarks         = Entity.Remarks;
            model.PurchaseYear    = Entity.PurchaseYear;
            model.PaymentStatus   = Entity.PaymentStatus;
            model.Remarks         = Entity.Remarks;
            model.RecordStatus    = Entity.RecordStatus;
            switch (Entity.RecordStatus)
            {
            case "NCF":
                model.RecordStatusName = "Not Confirmed";
                break;

            case "CNF":
                model.RecordStatusName = "Confirmed";
                break;

            case "APV":
                model.RecordStatusName = "Approved";
                break;

            //case "CMP":
            //    model.RecordStatusName = "Completed";
            //    break;
            default:
                model.RecordStatusName = "";
                break;
            }

            return(model);
        }
Пример #3
0
        public ValidationMsg Save(PrqBillPayment model, int userid)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        model.SetBy = userid;
                        Prq_BillPayment tblBillPayment = SetToModelObject(model);
                        _context.Prq_BillPayment.Add(tblBillPayment);
                        _context.SaveChanges();

                        #region Save Detail Records

                        if (model.BillPaymentReferenceList != null)
                        {
                            foreach (
                                PrqBillPaymentReference objPrqBillPaymentReference in
                                model.BillPaymentReferenceList)
                            {
                                objPrqBillPaymentReference.PaymentID    = tblBillPayment.PaymentID;
                                objPrqBillPaymentReference.RecordStatus = "NCF";
                                Prq_BillPaymentReference tblPurchaseYearPeriod =
                                    SetToModelObject(objPrqBillPaymentReference);
                                _context.Prq_BillPaymentReference.Add(tblPurchaseYearPeriod);
                            }
                        }
                        _context.SaveChanges();

                        #endregion

                        tx.Complete();
                        PaymentID   = tblBillPayment.PaymentID;
                        _vmMsg.Type = Enums.MessageType.Success;
                        _vmMsg.Msg  = "Saved Successfully.";
                    }
                }
            }
            catch
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to save.";
            }
            return(_vmMsg);
        }
Пример #4
0
        public ValidationMsg Update(PrqBillPayment model, int userid)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        model.ModifiedBy = userid;
                        Prq_BillPayment CurrentEntity  = SetToModelObject(model);
                        var             OriginalEntity = _context.Prq_BillPayment.First(m => m.PaymentID == model.PaymentID);

                        OriginalEntity.PaymentDate       = CurrentEntity.PaymentDate;// Convert.ToDateTime(Convert.ToDateTime(CurrentEntity.PaymentDate).ToString("dd/MM/yyyy"));
                        OriginalEntity.SupplierID        = CurrentEntity.SupplierID;
                        OriginalEntity.SupplierAddressID = CurrentEntity.SupplierAddressID;
                        OriginalEntity.PaymentType       = CurrentEntity.PaymentType;
                        OriginalEntity.PaymentMethod     = CurrentEntity.PaymentMethod;
                        OriginalEntity.Currency          = CurrentEntity.Currency;
                        OriginalEntity.PaymentDoc        = CurrentEntity.PaymentDoc;
                        OriginalEntity.BillAmount        = CurrentEntity.BillAmount;
                        OriginalEntity.VatPercentage     = CurrentEntity.VatPercentage;
                        OriginalEntity.VatAmount         = CurrentEntity.VatAmount;
                        OriginalEntity.DeductAmount      = CurrentEntity.DeductAmount;
                        OriginalEntity.PaymentAmount     = CurrentEntity.PaymentAmount;
                        OriginalEntity.Remarks           = CurrentEntity.Remarks;

                        OriginalEntity.ModifiedBy = userid;
                        OriginalEntity.ModifiedOn = DateTime.Now;

                        #region Save Detail Records

                        if (model.BillPaymentReferenceList != null)
                        {
                            foreach (PrqBillPaymentReference objPrqBillPaymentReference in model.BillPaymentReferenceList)
                            {
                                if (objPrqBillPaymentReference.PaymentID == 0)
                                {
                                    objPrqBillPaymentReference.PaymentID    = model.PaymentID;
                                    objPrqBillPaymentReference.RecordStatus = "NCF";
                                    Prq_BillPaymentReference tblPurchaseYearPeriod = SetToModelObject(objPrqBillPaymentReference);
                                    _context.Prq_BillPaymentReference.Add(tblPurchaseYearPeriod);
                                }
                                else
                                {
                                    Prq_BillPaymentReference CurEntity = SetToModelObject(objPrqBillPaymentReference);
                                    var OrgEntity = _context.Prq_BillPaymentReference.First(m => m.PaymentID == objPrqBillPaymentReference.PaymentID && m.SupplierBillID == objPrqBillPaymentReference.SupplierBillID);

                                    OrgEntity.SupplierBillRef = CurEntity.SupplierBillRef;
                                }
                            }
                        }
                        _context.SaveChanges();

                        #endregion

                        tx.Complete();
                        _vmMsg.Type = Enums.MessageType.Update;
                        _vmMsg.Msg  = "Updated Successfully.";
                    }
                }
            }
            catch
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to Update.";
            }
            return(_vmMsg);
        }