예제 #1
0
        public FinanceAllotmentDTO GetFinanceAllotment(int financeAllotmentId)
        {
            FinanceAllotmentDTO dto = new FinanceAllotmentDTO();

            try
            {
                using (var entity = new ManiMotorsEntities1())
                {
                    dto = (from vbfa in entity.VehicleBookingFinanceAllotments
                           join fi in entity.FinanceInfoes on vbfa.FinancierID equals fi.FinanceInfoID
                           where vbfa.VehicleBookingFinanceAllotmentID == financeAllotmentId
                           select new FinanceAllotmentDTO
                    {
                        VehicleBookingFinanceAllotmentID = financeAllotmentId,
                        VehicleBookingId = vbfa.VehicleBookingID,
                        FinancierName = fi.Name,
                        FinancierID = vbfa.FinancierID,
                        LoanNumber = vbfa.LoanNo,
                        FinanceDate = vbfa.FinanceDate,
                        FinanceAmount = vbfa.FinanceAmount,
                        OtherAmount = vbfa.OtherAmount,
                        OtherChargesDescription = vbfa.OtherChargesDesc
                    }
                           ).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dto);
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            FinanceAllotmentBL obj = new FinanceAllotmentBL();
            //FinancierId

            int financierId = 0;

            if (ddlFinance.SelectedIndex != -1)
            {
                var financeItem = (ComboboxItem)ddlFinance.SelectedItem;
                financierId = Convert.ToInt32(financeItem.Value);
            }

            int _loanNo = 0;

            if (txtLoanNo.Text != "")
            {
                _loanNo = Convert.ToInt32(txtLoanNo.Text);
            }

            int _financeAmt = 0;

            if (txtFinanceamt.Text != "")
            {
                _financeAmt = Convert.ToInt32(txtFinanceamt.Text);
            }

            int _otherAmt = 0;

            if (txtOtherChargesAmt.Text != "")
            {
                _otherAmt = Convert.ToInt32(txtOtherChargesAmt.Text);
            }

            //Populate dto
            FinanceAllotmentDTO dto = new FinanceAllotmentDTO()
            {
                VehicleBookingId        = Convert.ToInt32(lblVehicleBookingId.Text),
                FinancierID             = financierId,
                LoanNumber              = _loanNo,
                FinanceDate             = Convert.ToDateTime(dtFinanceDate.Text),
                FinanceAmount           = _financeAmt,
                OtherChargesDescription = txtOtherChargesDesc.Text,
                OtherAmount             = _otherAmt,
                CreatedBy    = GlobalSetup.Userid,
                CreatedDate  = DateTime.Now,
                ModifiedBy   = GlobalSetup.Userid,
                ModifiedDate = DateTime.Now
            };

            if (_mode == "EDIT")
            {
                dto.VehicleBookingFinanceAllotmentID = _financeAllotmentId;
            }

            int financeAllotmentId = obj.SaveFinanceAllotment(dto, _mode);

            lblFinanceAllotmentId.Text = financeAllotmentId.ToString();
            this.Close();
        }
예제 #3
0
        public int SaveFinanceAllotment(FinanceAllotmentDTO dto, string mode = "")
        {
            var financeAllotmentId = 0;

            try
            {
                using (var entity = new ManiMotorsEntities1())
                {
                    if (mode == "EDIT")
                    {
                        var obj = entity.VehicleBookingFinanceAllotments.FirstOrDefault(vbfa => vbfa.VehicleBookingFinanceAllotmentID == dto.VehicleBookingFinanceAllotmentID);
                        obj.VehicleBookingID = dto.VehicleBookingId;
                        obj.FinancierID      = dto.FinancierID;
                        obj.LoanNo           = dto.LoanNumber;
                        obj.FinanceDate      = dto.FinanceDate;
                        obj.FinanceAmount    = dto.FinanceAmount;
                        obj.OtherChargesDesc = dto.OtherChargesDescription;
                        obj.OtherAmount      = dto.OtherAmount;
                        obj.Createdby        = dto.CreatedBy;
                        obj.CreatedDate      = dto.CreatedDate;
                        obj.Modifiedby       = dto.ModifiedBy;
                        obj.ModifiedDate     = dto.ModifiedDate;
                        entity.SaveChanges();
                        financeAllotmentId = obj.VehicleBookingFinanceAllotmentID;
                    }
                    else
                    {
                        VehicleBookingFinanceAllotment obj = new VehicleBookingFinanceAllotment()
                        {
                            VehicleBookingID = dto.VehicleBookingId,
                            FinancierID      = dto.FinancierID,
                            LoanNo           = dto.LoanNumber,
                            FinanceDate      = dto.FinanceDate,
                            FinanceAmount    = dto.FinanceAmount,
                            OtherChargesDesc = dto.OtherChargesDescription,
                            OtherAmount      = dto.OtherAmount,
                            Createdby        = dto.CreatedBy,
                            CreatedDate      = dto.CreatedDate,
                            Modifiedby       = dto.ModifiedBy,
                            ModifiedDate     = dto.ModifiedDate
                        };
                        entity.VehicleBookingFinanceAllotments.Add(obj);
                        entity.SaveChanges();
                        financeAllotmentId = obj.VehicleBookingFinanceAllotmentID;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(financeAllotmentId);
        }
예제 #4
0
        public InvoiceDTO GetInvoiceDetails(int VehicleBookingId)
        {
            var Invoicedto     = new InvoiceDTO();
            var vBL            = new VehicleBookingBL();
            var viBL           = new VehicleInventoryBL();
            var vABL           = new VehicleAllotmentBL();
            var spABL          = new SparePartsAllotmentBL();
            var spInventory    = new SparePartsInventoryBL();
            var fABL           = new FinanceAllotmentBL();
            var vehicleBooking = vBL.GetVehicleBooking(VehicleBookingId);
            //Customer Information
            var ctmrDTO = new CustomerDTO();
            //VehicleInventory
            var vIDTO = new VehicleInventoryDTO();
            //VehicleBooking
            var vBDTO = new VehicleBookingDTO();
            //SpareParts Inventory
            var spInvDTOlist = new List <SparePartsInventoryDTO>();
            //Finance Allotment
            var fDTO = new FinanceAllotmentDTO();

            if (vehicleBooking != null)
            {
                vBDTO = vehicleBooking;
                Invoicedto.VclBooking = vBDTO;
                ctmrDTO.CustomerID    = vehicleBooking.CustomerID;
                ctmrDTO.Name          = vehicleBooking.CustomerName;
                Invoicedto.Customer   = ctmrDTO;
                //Get Vehicle Inventory ID from VehicleAllotment Id
                int vInventoryId = vABL.GeInventoryId(vehicleBooking.VehicleBookingAllotmentId ?? 0);

                if (vInventoryId != 0)
                {
                    var invDTO = viBL.GetVehicleInventory(vInventoryId);
                    vIDTO.EngineNo           = invDTO.EngineNo;
                    vIDTO.ChasisNo           = invDTO.ChasisNo;
                    vIDTO.VehicleModelName   = invDTO.VehicleModelName;
                    vIDTO.ExShowRoomPrice    = invDTO.ExShowRoomPrice;
                    vIDTO.LT_RT_OtherExp     = invDTO.LT_RT_OtherExp;
                    vIDTO.InsurancePrice     = invDTO.InsurancePrice;
                    vIDTO.OnRoadPrice        = invDTO.OnRoadPrice;
                    vIDTO.WarrantyPrice      = invDTO.WarrantyPrice;
                    vIDTO.VehicleInventoryID = vInventoryId;
                    if (invDTO.Is70PerMarginPrice)
                    {
                        vIDTO.MarginPrice = invDTO.Margin70;
                    }
                    if (invDTO.Is50PerMarginPrice)
                    {
                        vIDTO.MarginPrice = invDTO.Margin50;
                    }
                    Invoicedto.VehicleInventory = vIDTO;
                }

                //Get SpareParts Allotment Details
                var sPAltList = spABL.GetSparePartsAllotmentbyBookingId(VehicleBookingId);
                if (sPAltList.Count > 0)
                {
                    foreach (var sp in sPAltList)
                    {
                        var spIDTO = new SparePartsInventoryDTO();
                        if (sp.SparePartsInventoryID != 0)
                        {
                            var spI = spInventory.GetSparePartsInventory(sp.SparePartsInventoryID);
                            //SpareParts Inventory
                            SparePartsInventoryDTO spidto = new SparePartsInventoryDTO();
                            spidto.SparePartsInventoryID = sp.SparePartsInventoryID;
                            spidto.ShowRoomPrice         = spI.ShowRoomPrice;
                            spidto.MarginPrice           = spI.MarginPrice;
                            spidto.SparePartsModelName   = spI.SparePartsModelName;
                            spidto.SparePartsInfoID      = spI.SparePartsInfoID;
                            spInvDTOlist.Add(spidto);
                        }
                    }
                    Invoicedto.lstSparePartsInventory = spInvDTOlist;
                }

                //Finance Allotment

                if (vehicleBooking.FinanceAllotmentId != null && vehicleBooking.FinanceAllotmentId != 0)
                {
                    fDTO = fABL.GetFinanceAllotment(vehicleBooking.FinanceAllotmentId ?? 0);
                    Invoicedto.FinanceAllotment = fDTO;
                }
            }


            return(Invoicedto);
        }