Example #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var vehicleInventoryID = Convert.ToInt32(dgVehicleInventory.CurrentRow.Cells["VehicleInventoryID"].Value.ToString());

            if (vehicleInventoryID == 0)
            {
                MyMessageBox.ShowBox("Please select a value from the Vehicle Invetory!!!");
            }
            else
            {
                var retStr = MyMessageBoxYesorNo.ShowBox("Are you Sure You want to Delete??");
                if (retStr == "1")
                {
                    VehicleInventoryBL obj = new VehicleInventoryBL();
                    var flag = obj.DeleteVehicleInventory(vehicleInventoryID);
                    LoadDefaultValues();
                    if (flag)
                    {
                        MyMessageBox.ShowBox("Vehicle Inventory Deleted");
                    }
                    else
                    {
                        MyMessageBox.ShowBox("Vehicle Inventory Failed to Delete.");
                    }
                }
            }
        }
Example #2
0
        private void LoadDefaultValues()
        {
            //Load All Model Name
            VehicleInfoBL viBL = new VehicleInfoBL();

            foreach (var vehicleInfo in viBL.GetAllVehicleInfo())
            {
                ComboboxItem obj = new ComboboxItem();
                obj.Text  = vehicleInfo.ModelName;
                obj.Value = vehicleInfo.VehicleInfoID;
                ddlModelName.Items.Add(obj);
            }

            //Load Default Colors
            ddlColor.DataSource = GlobalSetup.colors;

            //Load Inventory Status
            ddlInvStatus.Items.Clear();
            VehicleInventoryBL obj2 = new VehicleInventoryBL();

            foreach (var status in obj2.GetInventoryStatusType())
            {
                ComboboxItem itemInventoryStatus = new ComboboxItem();
                itemInventoryStatus.Text  = status.Description;
                itemInventoryStatus.Value = status.VehicleInventoryStatusTypeID;
                ddlInvStatus.Items.Add(itemInventoryStatus);
            }
        }
Example #3
0
        private void PopulateSelectedAllotment(int vehicleAllotmentId)
        {
            VehicleAllotmentBL vaBl = new VehicleAllotmentBL();
            int vehicleInventoryId  = vaBl.GeInventoryId(vehicleAllotmentId);

            VehicleInventoryBL obj = new VehicleInventoryBL();
            var filterefInfo       = obj.GetAllVehicleInventory()
                                     .Where(
                i => i.VehicleInventoryID == vehicleInventoryId
                ).ToList();

            dgVehicleInventory.DataSource = filterefInfo;
        }
Example #4
0
        private void LoadDefaultValues()
        {
            VehicleInventoryBL obj = new VehicleInventoryBL();
            var lst = obj.GetAllVehicleInventory();


            if (_mode == "ADD")
            {
                lst = lst.Where(i => i.VehicleInventoryStatusTypeID == 1).ToList();
            }
            dgVehicleInventory.DataSource = lst;
            //Get All Model Name
            VehicleInfoBL obj1       = new VehicleInfoBL();
            var           allVehInfo = obj1.GetAllVehicleInfo();

            ddlModelName.Items.Clear();
            ddlModelCode.Items.Clear();
            foreach (var vehInfo in allVehInfo)
            {
                //Load Model Name
                ComboboxItem itemModelName = new ComboboxItem();
                itemModelName.Text  = vehInfo.ModelName;
                itemModelName.Value = vehInfo.VehicleInfoID;
                ddlModelName.Items.Add(itemModelName);

                //Load Model Code
                ComboboxItem itemModelcode = new ComboboxItem();
                itemModelcode.Text  = vehInfo.ModelCode;
                itemModelcode.Value = vehInfo.VehicleInfoID;
                ddlModelCode.Items.Add(itemModelcode);
            }


            //Load Inventory Status
            ddlInventoryStatus.Items.Clear();
            VehicleInventoryBL obj2 = new VehicleInventoryBL();

            foreach (var status in obj2.GetInventoryStatusType())
            {
                ComboboxItem itemInventoryStatus = new ComboboxItem();
                itemInventoryStatus.Text  = status.Description;
                itemInventoryStatus.Value = status.VehicleInventoryStatusTypeID;
                ddlInventoryStatus.Items.Add(itemInventoryStatus);
            }

            //Load Colors
            ddlColor.DataSource    = GlobalSetup.colors;
            ddlColor.SelectedIndex = -1;
        }
Example #5
0
        private void PopulateInventoryVehicle(int vehicleInventoryID)
        {
            VehicleInventoryBL obj = new VehicleInventoryBL();
            var          vehInv    = obj.GetAllVehicleInventory().Where(v => v.VehicleInventoryID == vehicleInventoryID).FirstOrDefault();
            ComboboxItem selitem   = new ComboboxItem();

            selitem.Text           = vehInv.VehicleModelName;
            selitem.Value          = vehInv.VehicleInfoID;
            ddlModelName.Text      = selitem.Text;
            txtChasisNo.Text       = vehInv.ChasisNo;
            txtEngineNo.Text       = vehInv.EngineNo;
            ddlColor.SelectedItem  = vehInv.Color;
            dtMfgDate.Value        = vehInv.MfgDate;
            txtKeyNo.Text          = vehInv.KeyNo;
            txtBatteryMake.Text    = vehInv.BatteryMake;
            txtBatteryNo.Text      = vehInv.BatteryNo;
            txtServiceBookNo.Text  = vehInv.ServiceBookNo;
            rdnMarginPrice.Checked = vehInv.IsMarginPrice;
            rdn50Margin.Checked    = vehInv.Is50PerMarginPrice;
            rdn70Margin.Checked    = vehInv.Is70PerMarginPrice;
            //InventoryStatus Populate
            var          vehInvStatus = obj.GetInventoryStatusType().Where(iv => iv.VehicleInventoryStatusTypeID == vehInv.VehicleInventoryStatusTypeID).FirstOrDefault();
            ComboboxItem selInvitem   = new ComboboxItem();

            selInvitem.Text   = vehInvStatus.Description;
            selInvitem.Value  = vehInvStatus.VehicleInventoryStatusTypeID;
            ddlInvStatus.Text = selInvitem.Text;

            txtShowRoomPrice.Text  = vehInv.ExShowRoomPrice.ToString();
            txtLTRTOtherExp.Text   = vehInv.LT_RT_OtherExp.ToString();
            txtInsurancePrice.Text = vehInv.InsurancePrice.ToString();
            txtMarginPrice.Text    = vehInv.MarginPrice.ToString();
            txt50Margin.Text       = vehInv.Margin50.ToString();
            txt70Margin.Text       = vehInv.Margin70.ToString();
            txtWarranty.Text       = vehInv.WarrantyPrice.ToString();
            txtOnRoadPrice.Text    = vehInv.OnRoadPrice.ToString();
            txtRemarks.Text        = vehInv.Remarks;
        }
Example #6
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //var modelCode = txtModelCode.Text;
            var    modelName = ddlModelName.SelectedText;
            var    modelCode = ddlModelCode.SelectedText;
            string color     = "";

            if (ddlColor.SelectedItem != null)
            {
                color = ddlColor.SelectedItem.ToString();
            }
            string inventoryStatus = "";

            if (ddlInventoryStatus.SelectedItem != null)
            {
                inventoryStatus = ddlInventoryStatus.SelectedItem.ToString();
            }
            var chasisNo           = txtChasisNo.Text;
            var engineNo           = txtEngineNo.Text;
            VehicleInventoryBL obj = new VehicleInventoryBL();
            var filterefInfo       = obj.GetAllVehicleInventory()
                                     .Where(
                i => i.VehicleModelName.ToUpper().Contains(modelName.ToUpper())
                &&
                i.VehicleModelCode.ToUpper().Contains(modelCode.ToUpper())
                &&
                i.ChasisNo.ToUpper().Contains(chasisNo.ToUpper())
                &&
                i.EngineNo.ToUpper().Contains(engineNo.ToUpper())
                &&
                i.Color.ToUpper().Contains(color.ToUpper())
                &&
                i.VehicleInventoryStatusName.ToUpper().Contains(inventoryStatus.ToUpper())
                ).ToList();

            dgVehicleInventory.DataSource = filterefInfo;
        }
Example #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ddlModelName.SelectedIndex == -1 || txtChasisNo.Text == "" || txtEngineNo.Text == "" || ddlColor.SelectedIndex == -1 || txtServiceBookNo.Text == "" || txtKeyNo.Text == "" || txtBatteryNo.Text == "" || txtBatteryMake.Text == "" || ddlInvStatus.SelectedIndex == -1 || txtShowRoomPrice.Text == "" || txtLTRTOtherExp.Text == "" || txtInsurancePrice.Text == "" || txtMarginPrice.Text == "" || txt50Margin.Text == "" || txt70Margin.Text == "" || txtWarranty.Text == "" || txtOnRoadPrice.Text == "" || (!rdn50Margin.Checked && !rdn70Margin.Checked && !rdnMarginPrice.Checked))
            {
                MyMessageBox.ShowBox("Please Select All Mandatory Fields !!!");
                return;
            }

            if (txtShowRoomPrice.Text == "0" || txtLTRTOtherExp.Text == "0" || txtInsurancePrice.Text == "0" || txtMarginPrice.Text == "0" || txt50Margin.Text == "0" || txt70Margin.Text == "0" || txtWarranty.Text == "0" || txtOnRoadPrice.Text == "0")
            {
                MyMessageBox.ShowBox("Price cannot be 0 !!!");
                return;
            }

            if (ddlInvStatus.SelectedIndex != 0 && txtRemarks.Text == "")
            {
                MyMessageBox.ShowBox("Remarks Cannot be Empty !!!");
                return;
            }
            VehicleInventoryDTO info = new VehicleInventoryDTO();
            var selItem = (ComboboxItem)ddlModelName.SelectedItem;

            info.VehicleInventoryID = _vehicleInventoryID;
            info.VehicleInfoID      = Convert.ToInt32(selItem.Value);
            info.ChasisNo           = txtChasisNo.Text;
            info.EngineNo           = txtEngineNo.Text;
            info.Color              = ddlColor.SelectedItem.ToString();
            info.MfgDate            = Convert.ToDateTime(dtMfgDate.Text);
            info.KeyNo              = txtKeyNo.Text;
            info.BatteryMake        = txtBatteryMake.Text;
            info.BatteryNo          = txtBatteryNo.Text;
            info.ServiceBookNo      = txtServiceBookNo.Text;
            info.CreatedDate        = System.DateTime.Now;
            info.CreatedBy          = GlobalSetup.Userid;
            info.ModifiedDate       = System.DateTime.Now;
            info.ModifiedBy         = GlobalSetup.Userid;
            info.Is50PerMarginPrice = rdn50Margin.Checked;
            info.Is70PerMarginPrice = rdn70Margin.Checked;
            info.IsMarginPrice      = rdnMarginPrice.Checked;
            info.ExShowRoomPrice    = Convert.ToInt32(txtShowRoomPrice.Text);
            info.LT_RT_OtherExp     = Convert.ToInt32(txtLTRTOtherExp.Text);
            info.InsurancePrice     = Convert.ToInt32(txtInsurancePrice.Text);
            info.OnRoadPrice        = Convert.ToInt32(txtOnRoadPrice.Text);
            info.MarginPrice        = Convert.ToInt32(txtMarginPrice.Text);
            info.Margin50           = Convert.ToInt32(txt50Margin.Text);
            info.Margin70           = Convert.ToInt32(txt70Margin.Text);
            info.WarrantyPrice      = Convert.ToInt32(txtWarranty.Text);
            info.Remarks            = txtRemarks.Text;
            var invSelitem = (ComboboxItem)ddlInvStatus.SelectedItem;

            info.VehicleInventoryStatusTypeID = Convert.ToInt32(invSelitem.Value);
            info.Remarks = txtRemarks.Text;

            VehicleInventoryBL viBL = new VehicleInventoryBL();
            var flag = viBL.SaveInventoryVehicle(info, _mode);

            if (flag)
            {
                MyMessageBox.ShowBox("Vehicle Inventory Saved", "Vehicle Inventory");
                Clear();
            }
            else
            {
                MyMessageBox.ShowBox("Vehicle Inventory Failed to Save", "Vehicle Inventory");
            }

            this.Close();
        }
Example #8
0
        public InvoiceMarginGridDTO GetInvoiceMarginDTO(int vehicleBookingId)
        {
            InvoiceMarginGridDTO dto = new InvoiceMarginGridDTO();

            using (var entities = new ManiMotorsEntities1())
            {
                var marginList = entities.InvoiceMargins.Where(x => x.VehicleBookingID == vehicleBookingId).ToList();
                if (marginList != null && marginList.Count > 0)
                {
                    var distintmarginLst = marginList.GroupBy(x => x.VehicleBookingID).Select(y => y.First()).FirstOrDefault();

                    //foreach (var marginlist in distintmarginLst)
                    {
                        var bookingId = distintmarginLst.VehicleBookingID;
                        //Invoice Margin Grid DTO for each booking
                        InvoiceMarginGridDTO gDTO = new InvoiceMarginGridDTO();

                        //Get VehicleDetails
                        var IAMargin = marginList.Where(x => x.MarginTypeID == 1 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (IAMargin != null)
                        {
                            var vehicleInventoryId = IAMargin.MarginID;
                            VehicleInventoryBL vBL = new VehicleInventoryBL();
                            //Get Inventory Details
                            var vDTO = vBL.GetVehicleInventory(vehicleInventoryId ?? 0);
                            gDTO.VehicleBookingId      = bookingId;
                            gDTO.InvoiceDate           = IAMargin.InvoiceDate;
                            gDTO.ModelName             = vDTO.VehicleModelName;
                            gDTO.EngineNo              = vDTO.EngineNo;
                            gDTO.ChasisNo              = vDTO.ChasisNo;
                            gDTO.ShowRoomPrice         = vDTO.ExShowRoomPrice;
                            gDTO.OnRoadPrice           = vDTO.OnRoadPrice;
                            gDTO.ManiMotorsInvoiceDate = IAMargin.InvoiceDate;
                            gDTO.IAInvoiceDate         = IAMargin.IAInvoiceDate;
                            if (vDTO.Is50PerMarginPrice)
                            {
                                gDTO.IA40PercentMargin        = vDTO.Margin50;
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IA40PercentMargin * .90);
                            }
                            else if (vDTO.Is70PerMarginPrice)
                            {
                                gDTO.IA70PercentMargin        = vDTO.Margin70;
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IA70PercentMargin * .90);
                            }
                            else if (vDTO.IsMarginPrice)
                            {
                                gDTO.IA100PercentMargin       = vDTO.MarginPrice;
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IA100PercentMargin * .90);
                            }
                            gDTO.IAMarginManualAmount = IAMargin.ManualAmount;
                            if (gDTO.IAMarginManualAmount != 0 && gDTO.IAMarginManualAmount != null)
                            {
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IAMarginManualAmount * .90);
                            }

                            gDTO.IAMarginReceivedByCash   = IAMargin.IsCash;
                            gDTO.IAMarginByChequeorNEFTNo = IAMargin.ChequeOrBankTranNo;
                            gDTO.IAMarginReceivedDate     = IAMargin.ReceivedDate;
                            gDTO.IAMarginReceived         = IAMargin.IsReceived;
                            gDTO.IARemarks = IAMargin.Remarks;
                            //Get Customer Details
                            var vb = entities.VehicleBookings.FirstOrDefault(x => x.VehicleBookingID == bookingId);
                            if (vb != null)
                            {
                                CustomerBL cBL  = new CustomerBL();
                                var        cust = cBL.GetCustomer(vb.CustomerID);
                                if (cust != null)
                                {
                                    gDTO.CustomerName     = cust.Name;
                                    gDTO.CustomerID       = cust.CustomerID;
                                    gDTO.CustomerMobileNo = cust.ContactNo;
                                }
                            }
                        }
                        //Vehicle and IA Margin Complete

                        //- Get Finance Margin
                        var FAMargin = marginList.Where(x => x.MarginTypeID == 2 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (FAMargin != null)
                        {
                            var fInfo = entities.FinanceInfoes.FirstOrDefault(x => x.FinanceInfoID == FAMargin.MarginID);
                            if (fInfo != null)
                            {
                                gDTO.FinanceBy = fInfo.Name;
                            }
                            gDTO.FinanceAmount                 = FAMargin.ActualAmount;
                            gDTO.FinanceMargin                 = FAMargin.MarginAmount;
                            gDTO.FinanceMarginManualAmount     = FAMargin.ManualAmount;
                            gDTO.FinanceMarginReceivedDate     = FAMargin.ReceivedDate;
                            gDTO.FinanceMarginReceived         = FAMargin.IsReceived;
                            gDTO.FinanceRemarks                = FAMargin.Remarks;
                            gDTO.FinanceMarginReceivedByCash   = FAMargin.IsCash;
                            gDTO.FinanceMarginByChequeorNEFTNo = FAMargin.ChequeOrBankTranNo;
                        }

                        //Get Extra Fittings Margin
                        var EFMargin = marginList.Where(x => x.MarginTypeID == 4 && x.VehicleBookingID == bookingId).ToList();
                        if (EFMargin != null && EFMargin.Count > 0)
                        {
                            int totalActualAmount = EFMargin.Sum(x => x.ActualAmount) ?? 0;
                            int totalMarginAmount = EFMargin.Sum(x => x.MarginAmount) ?? 0;
                            int totalManualAmount = EFMargin.FirstOrDefault().ManualAmount ?? 0;
                            gDTO.ExtraFittingsTotalActualAmount      = totalActualAmount;
                            gDTO.ExtraFittingsTotalMarginAmount      = totalMarginAmount;
                            gDTO.ExtraFittingsManualMarginAmount     = totalManualAmount;
                            gDTO.ExtraFittingsRemarks                = EFMargin.FirstOrDefault().Remarks;
                            gDTO.ExtraFittingsReceivedDate           = EFMargin.FirstOrDefault().ReceivedDate;
                            gDTO.ExtraFittingsReceived               = EFMargin.FirstOrDefault().IsReceived;
                            gDTO.ExtraFittingsReceivedByCash         = EFMargin.FirstOrDefault().IsCash;
                            gDTO.ExtraFittingsMarginByChequeorNEFTNo = EFMargin.FirstOrDefault().ChequeOrBankTranNo;
                        }

                        //Get Warranty Margin

                        var wMargin = marginList.Where(x => x.MarginTypeID == 3 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (wMargin != null)
                        {
                            gDTO.WarrantyPrice                  = wMargin.ActualAmount;
                            gDTO.WarrantyMarginPrice            = wMargin.MarginAmount;
                            gDTO.WarrantyMarginReceivedByCash   = wMargin.IsCash;
                            gDTO.WarrantyMarginByChequeorNEFTNo = wMargin.ChequeOrBankTranNo;
                            gDTO.WarrantyMarginReceivedDate     = wMargin.ReceivedDate;
                            gDTO.WarrantyMarginManualAmount     = wMargin.ManualAmount;
                            if (wMargin.ManualAmount != null && wMargin.ManualAmount != 0)
                            {
                                gDTO.WarrantyMarginwithDTSDeduction = Convert.ToInt32(wMargin.ManualAmount * 0.9);
                            }
                            else
                            {
                                gDTO.WarrantyMarginwithDTSDeduction = Convert.ToInt32(wMargin.MarginAmount * 0.9);
                            }
                            gDTO.WarrantyMarginRemarks  = wMargin.Remarks;
                            gDTO.WarrantyMarginReceived = wMargin.IsReceived;
                        }
                        //Get Discount Margin
                        var dMargin = marginList.Where(x => x.MarginTypeID == 5 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (dMargin != null)
                        {
                            gDTO.DiscountGiven   = dMargin.MarginAmount;
                            gDTO.DiscountRemarks = dMargin.Remarks;
                        }
                        dto = gDTO;
                    }
                }
            }
            return(dto);
        }
Example #9
0
        public List <InvoiceMarginGridDTO> GetInvoiceMarginDTOList(DateTime startDate, DateTime endDate, string invoiceType)
        {
            List <InvoiceMarginGridDTO> lst = new List <InvoiceMarginGridDTO>();

            using (var entities = new ManiMotorsEntities1())
            {
                List <InvoiceMargin> marginList = new List <InvoiceMargin>();
                if (invoiceType.ToUpper() == "IA")
                {
                    marginList = entities.InvoiceMargins.Where(x => x.IAInvoiceDate >= startDate && x.IAInvoiceDate <= endDate).ToList().OrderBy(x => x.VehicleBookingID).ToList();
                }
                else if (invoiceType.ToUpper() == "MANIMOTORS")
                {
                    marginList = entities.InvoiceMargins.Where(x => x.InvoiceDate >= startDate && x.InvoiceDate <= endDate).ToList().OrderBy(x => x.VehicleBookingID).ToList();
                }

                if (marginList != null && marginList.Count > 0)
                {
                    //lst.GroupBy(x => x.VehicleBookingID).Select(y => y.First()).ToList();
                    var distintmarginLst = marginList.GroupBy(x => x.VehicleBookingID).Select(y => y.First()).ToList();

                    foreach (var marginlist in distintmarginLst)
                    {
                        var bookingId = marginlist.VehicleBookingID;
                        //Invoice Margin Grid DTO for each booking
                        InvoiceMarginGridDTO gDTO = new InvoiceMarginGridDTO();

                        //Get VehicleDetails
                        var IAMargin = marginList.Where(x => x.MarginTypeID == 1 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (IAMargin != null)
                        {
                            var vehicleInventoryId = IAMargin.MarginID;
                            VehicleInventoryBL vBL = new VehicleInventoryBL();
                            //Get Inventory Details
                            var vDTO = vBL.GetVehicleInventory(vehicleInventoryId ?? 0);
                            gDTO.VehicleBookingId      = bookingId;
                            gDTO.InvoiceDate           = IAMargin.InvoiceDate;
                            gDTO.ModelName             = vDTO.VehicleModelName;
                            gDTO.EngineNo              = vDTO.EngineNo;
                            gDTO.ChasisNo              = vDTO.ChasisNo;
                            gDTO.ShowRoomPrice         = vDTO.ExShowRoomPrice;
                            gDTO.OnRoadPrice           = vDTO.OnRoadPrice;
                            gDTO.ManiMotorsInvoiceDate = IAMargin.InvoiceDate;
                            gDTO.IAInvoiceDate         = IAMargin.IAInvoiceDate;
                            if (vDTO.Is50PerMarginPrice)
                            {
                                gDTO.IA40PercentMargin        = vDTO.Margin50;
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IA40PercentMargin * .90);
                            }
                            else if (vDTO.Is70PerMarginPrice)
                            {
                                gDTO.IA70PercentMargin        = vDTO.Margin70;
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IA70PercentMargin * .90);
                            }
                            else if (vDTO.IsMarginPrice)
                            {
                                gDTO.IA100PercentMargin       = vDTO.MarginPrice;
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IA100PercentMargin * .90);
                            }
                            gDTO.IAMarginManualAmount = IAMargin.ManualAmount;
                            if (gDTO.IAMarginManualAmount != 0 && gDTO.IAMarginManualAmount != null)
                            {
                                gDTO.IAMarginwithDTSDeduction = Convert.ToInt32(gDTO.IAMarginManualAmount * .90);
                            }

                            gDTO.IAMarginReceivedByCash   = IAMargin.IsCash;
                            gDTO.IAMarginByChequeorNEFTNo = IAMargin.ChequeOrBankTranNo;
                            gDTO.IAMarginReceivedDate     = IAMargin.ReceivedDate;
                            gDTO.IAMarginReceived         = IAMargin.IsReceived;
                            gDTO.IARemarks = IAMargin.Remarks;
                            //Get Customer Details
                            var vb = entities.VehicleBookings.FirstOrDefault(x => x.VehicleBookingID == bookingId);
                            if (vb != null)
                            {
                                CustomerBL cBL  = new CustomerBL();
                                var        cust = cBL.GetCustomer(vb.CustomerID);
                                if (cust != null)
                                {
                                    gDTO.CustomerName     = cust.Name;
                                    gDTO.CustomerID       = cust.CustomerID;
                                    gDTO.CustomerMobileNo = cust.ContactNo;
                                }
                            }

                            //Margin Calculation
                            if (gDTO.IAMarginReceivedByCash ?? false)
                            {
                                if (gDTO.IAMarginReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_Cash = gDTO.TotalMarginReceived_Cash + (gDTO.IAMarginManualAmount == 0 || gDTO.IAMarginManualAmount == null ? gDTO.IAMarginwithDTSDeduction ?? 0 : gDTO.IAMarginManualAmount ?? 0);
                                }
                            }
                            else
                            {
                                if (gDTO.IAMarginReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_ChequeorBank = gDTO.TotalMarginReceived_ChequeorBank + (gDTO.IAMarginManualAmount == 0 || gDTO.IAMarginManualAmount == null ?  gDTO.IAMarginwithDTSDeduction ?? 0 : gDTO.IAMarginManualAmount ?? 0);
                                }
                            }

                            gDTO.TotalMarginAmount = gDTO.TotalMarginAmount + (gDTO.IAMarginManualAmount == 0 || gDTO.IAMarginManualAmount == null ? gDTO.IAMarginwithDTSDeduction ?? 0 : gDTO.IAMarginManualAmount ?? 0);
                        }
                        //Vehicle and IA Margin Complete

                        //- Get Finance Margin
                        var FAMargin = marginList.Where(x => x.MarginTypeID == 2 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (FAMargin != null)
                        {
                            var fInfo = entities.FinanceInfoes.FirstOrDefault(x => x.FinanceInfoID == FAMargin.MarginID);
                            if (fInfo != null)
                            {
                                gDTO.FinanceBy = fInfo.Name;
                            }
                            gDTO.FinanceAmount                 = FAMargin.ActualAmount;
                            gDTO.FinanceMargin                 = FAMargin.MarginAmount;
                            gDTO.FinanceMarginManualAmount     = FAMargin.ManualAmount;
                            gDTO.FinanceMarginReceivedDate     = FAMargin.ReceivedDate;
                            gDTO.FinanceMarginReceived         = FAMargin.IsReceived;
                            gDTO.FinanceRemarks                = FAMargin.Remarks;
                            gDTO.FinanceMarginReceivedByCash   = FAMargin.IsCash;
                            gDTO.FinanceMarginByChequeorNEFTNo = FAMargin.ChequeOrBankTranNo;

                            //Margin Calculation
                            if (gDTO.FinanceMarginReceivedByCash ?? false)
                            {
                                if (gDTO.FinanceMarginReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_Cash = gDTO.TotalMarginReceived_Cash + (gDTO.FinanceMarginManualAmount == 0 || gDTO.FinanceMarginManualAmount == null ? gDTO.FinanceMargin ?? 0 : gDTO.FinanceMarginManualAmount ?? 0);
                                }
                            }
                            else
                            {
                                if (gDTO.FinanceMarginReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_ChequeorBank = gDTO.TotalMarginReceived_ChequeorBank + (gDTO.FinanceMarginManualAmount == 0 || gDTO.FinanceMarginManualAmount == null ? gDTO.FinanceMargin ?? 0 : gDTO.FinanceMarginManualAmount ?? 0);
                                }
                            }

                            gDTO.TotalMarginAmount = gDTO.TotalMarginAmount + (gDTO.FinanceMarginManualAmount == 0 || gDTO.FinanceMarginManualAmount == null ? gDTO.FinanceMargin ?? 0 : gDTO.FinanceMarginManualAmount ?? 0);
                        }

                        //Get Extra Fittings Margin
                        var EFMargin = marginList.Where(x => x.MarginTypeID == 4 && x.VehicleBookingID == bookingId).ToList();
                        if (EFMargin != null && EFMargin.Count > 0)
                        {
                            int totalActualAmount = EFMargin.Sum(x => x.ActualAmount) ?? 0;
                            int totalMarginAmount = EFMargin.Sum(x => x.MarginAmount) ?? 0;
                            int totalManualAmount = EFMargin.FirstOrDefault().ManualAmount ?? 0;
                            gDTO.ExtraFittingsTotalActualAmount      = totalActualAmount;
                            gDTO.ExtraFittingsTotalMarginAmount      = totalMarginAmount;
                            gDTO.ExtraFittingsManualMarginAmount     = totalManualAmount;
                            gDTO.ExtraFittingsRemarks                = EFMargin.FirstOrDefault().Remarks;
                            gDTO.ExtraFittingsReceivedDate           = EFMargin.FirstOrDefault().ReceivedDate;
                            gDTO.ExtraFittingsReceived               = EFMargin.FirstOrDefault().IsReceived;
                            gDTO.ExtraFittingsReceivedByCash         = EFMargin.FirstOrDefault().IsCash;
                            gDTO.ExtraFittingsMarginByChequeorNEFTNo = EFMargin.FirstOrDefault().ChequeOrBankTranNo;

                            //Margin Calculation
                            if (gDTO.ExtraFittingsReceivedByCash ?? false)
                            {
                                if (gDTO.ExtraFittingsReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_Cash = gDTO.TotalMarginReceived_Cash + (gDTO.ExtraFittingsManualMarginAmount == 0 || gDTO.ExtraFittingsManualMarginAmount == null ? gDTO.ExtraFittingsTotalActualAmount ?? 0 : gDTO.ExtraFittingsManualMarginAmount ?? 0);
                                }
                            }
                            else
                            {
                                if (gDTO.ExtraFittingsReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_ChequeorBank = gDTO.TotalMarginReceived_ChequeorBank + (gDTO.ExtraFittingsManualMarginAmount == 0 || gDTO.ExtraFittingsManualMarginAmount == null ? gDTO.ExtraFittingsTotalActualAmount ?? 0 : gDTO.ExtraFittingsManualMarginAmount ?? 0);
                                }
                            }

                            gDTO.TotalMarginAmount = gDTO.TotalMarginAmount + (gDTO.ExtraFittingsManualMarginAmount == 0 || gDTO.ExtraFittingsManualMarginAmount == null ? gDTO.ExtraFittingsTotalMarginAmount ?? 0 : gDTO.ExtraFittingsManualMarginAmount ?? 0);
                            gDTO.ExtraFittingsActualMarginAmount = (gDTO.ExtraFittingsManualMarginAmount == 0 || gDTO.ExtraFittingsManualMarginAmount == null ? gDTO.ExtraFittingsTotalMarginAmount ?? 0 : gDTO.ExtraFittingsManualMarginAmount ?? 0);
                        }

                        //Get Warranty Margin

                        var wMargin = marginList.Where(x => x.MarginTypeID == 3 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (wMargin != null)
                        {
                            gDTO.WarrantyPrice                  = wMargin.ActualAmount;
                            gDTO.WarrantyMarginPrice            = wMargin.MarginAmount;
                            gDTO.WarrantyMarginReceivedByCash   = wMargin.IsCash;
                            gDTO.WarrantyMarginByChequeorNEFTNo = wMargin.ChequeOrBankTranNo;
                            gDTO.WarrantyMarginReceivedDate     = wMargin.ReceivedDate;
                            gDTO.WarrantyMarginManualAmount     = wMargin.ManualAmount;
                            if (wMargin.ManualAmount != null && wMargin.ManualAmount != 0)
                            {
                                gDTO.WarrantyMarginwithDTSDeduction = Convert.ToInt32(wMargin.ManualAmount * 0.9);
                            }
                            else
                            {
                                gDTO.WarrantyMarginwithDTSDeduction = Convert.ToInt32(wMargin.MarginAmount * 0.9);
                            }
                            gDTO.WarrantyMarginRemarks  = wMargin.Remarks;
                            gDTO.WarrantyMarginReceived = wMargin.IsReceived;

                            //Margin Calculation
                            if (gDTO.WarrantyMarginReceivedByCash)
                            {
                                if (gDTO.WarrantyMarginReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_Cash = gDTO.TotalMarginReceived_Cash + (gDTO.WarrantyMarginManualAmount == 0 || gDTO.WarrantyMarginManualAmount == null ? gDTO.WarrantyMarginwithDTSDeduction ?? 0 : gDTO.WarrantyMarginManualAmount ?? 0);
                                }
                            }
                            else
                            {
                                if (gDTO.WarrantyMarginReceived ?? false)
                                {
                                    gDTO.TotalMarginReceived_ChequeorBank = gDTO.TotalMarginReceived_ChequeorBank + (gDTO.WarrantyMarginManualAmount == 0 || gDTO.WarrantyMarginManualAmount == null ? gDTO.WarrantyMarginwithDTSDeduction ?? 0 : gDTO.WarrantyMarginManualAmount ?? 0);
                                }
                            }

                            gDTO.TotalMarginAmount = gDTO.TotalMarginAmount + (gDTO.WarrantyMarginManualAmount == 0 || gDTO.WarrantyMarginManualAmount == null ? gDTO.WarrantyMarginwithDTSDeduction ?? 0 : gDTO.WarrantyMarginManualAmount ?? 0);
                        }
                        //Get Discount Margin
                        var dMargin = marginList.Where(x => x.MarginTypeID == 5 && x.VehicleBookingID == bookingId).FirstOrDefault();
                        if (dMargin != null)
                        {
                            gDTO.DiscountGiven   = dMargin.MarginAmount;
                            gDTO.DiscountRemarks = dMargin.Remarks;
                        }
                        gDTO.NetProfit = (gDTO.TotalMarginAmount + Convert.ToInt32(gDTO.DiscountGiven ?? 0));
                        gDTO.TotalMarginReceived_Cash     = gDTO.TotalMarginReceived_Cash + Convert.ToInt32(gDTO.DiscountGiven ?? 0);
                        gDTO.TotalMarginPending           = Convert.ToInt32((gDTO.TotalMarginAmount - (gDTO.TotalMarginReceived_Cash + gDTO.TotalMarginReceived_ChequeorBank))) + Convert.ToInt32(gDTO.DiscountGiven ?? 0);
                        gDTO.TotalAmountWithExtraFittings = Convert.ToInt32((gDTO.NetProfit - gDTO.ExtraFittingsActualMarginAmount)) + Convert.ToInt32(gDTO.ExtraFittingsTotalActualAmount ?? 0);
                        lst.Add(gDTO);
                    }
                }
            }
            return(lst);
        }
Example #10
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);
        }