private void PopulateVehicleBooking(int vehicleBookingId)
        {
            VehicleBookingBL vBl = new VehicleBookingBL();
            var vclBooking       = vBl.GetVehicleBooking(vehicleBookingId);

            _vehicleEnquiryId = vclBooking.VehicleEnquiryID ?? 0;
            //Assign EnquiryInformation to form
            txtCustomerName.Text = vclBooking.CustomerName;
            txtCustomerId.Text   = vclBooking.CustomerID.ToString();
            txtReferenceBy.Text  = vclBooking.ReferenceBy;
            //Employees
            ComboboxItem empItem = new ComboboxItem();

            empItem.Text      = vclBooking.SalesExecutiveName;
            empItem.Value     = vclBooking.SalesExecutiveId;
            ddlEmployees.Text = empItem.Text;

            //Model1
            if (vclBooking.ModelID != 0)
            {
                ComboboxItem model1item = new ComboboxItem();
                model1item.Text  = vclBooking.ModelName;
                model1item.Value = vclBooking.ModelID;
                ddlModel.Text    = model1item.Text;
            }

            //Bind Colors
            ddlColor1.Text = vclBooking.Color1;
            ddlColor2.Text = vclBooking.Color2;
            ddlColor3.Text = vclBooking.Color3;

            txtCustomerRemark.Text = vclBooking.CustomerRemark;

            //Advance Amount assigning
            string advAmount = "";

            if (vclBooking.AdvanceAmount != null || vclBooking.AdvanceAmount != 0)
            {
                advAmount = vclBooking.AdvanceAmount.ToString();
            }

            txtAdvanceAmount.Text = advAmount;

            //Advance Mode
            if (vclBooking.AdvanceMode)
            {
                rdnAdvCash.Checked   = true;
                rdnAdvCheque.Checked = false;
            }
            else
            {
                rdnAdvCash.Checked   = false;
                rdnAdvCheque.Checked = true;
            }
            //Advance Cheque no assigning
            string cheqNo = "";

            if (vclBooking.AdvanceChequeNo != null || vclBooking.AdvanceChequeNo != 0)
            {
                cheqNo = vclBooking.AdvanceChequeNo.ToString();
            }

            txtChequeNo.Text = cheqNo;

            //Payment
            if (vclBooking.IsCash)
            {
                rdnPayCash.Checked    = true;
                rdnPayFinance.Checked = false;
            }
            else
            {
                rdnPayCash.Checked    = false;
                rdnPayFinance.Checked = true;
            }

            //Financier
            if (vclBooking.FinancierInfoId != 0)
            {
                ComboboxItem financeItem = new ComboboxItem();
                financeItem.Text  = vclBooking.FinancierName;
                financeItem.Value = vclBooking.FinancierInfoId;
                ddlFinance.Text   = financeItem.Text;
            }

            txtFinanceRemark.Text = vclBooking.FinancierRemark;

            if (vclBooking.ReadyToDeliver ?? false)
            {
                rdnRtoDYes.Checked = true;
            }
            else
            {
                rdnRToDNo.Checked = true;
            }

            //Status
            ComboboxItem statusItem = new ComboboxItem();

            statusItem.Text  = vclBooking.StatusDescription;
            statusItem.Value = vclBooking.StatusId;
            ddlStatus.Text   = statusItem.Text;

            dtCommittedDate.Text = vclBooking.CommittedDate.ToString();

            //Populate followup records
            VehicleBookingFollowUpBL vbfBL = new VehicleBookingFollowUpBL();
            var bookingFollowup            = vbfBL.GetVehicleBookingFollowupbyId(vehicleBookingId);

            lblPrevRemark1.Text = bookingFollowup.Description;
            dtFollowupDate.Text = bookingFollowup.FollowUpDate.ToString();

            //Populate Allotments
            if (vclBooking.VehicleBookingAllotmentId != 0)
            {
                if (vclBooking.VehicleBookingAllotmentId.ToString() != "")
                {
                    VehicleAllotmentBL bl = new VehicleAllotmentBL();
                    int inventoryId       = bl.GeInventoryId(vclBooking.VehicleBookingAllotmentId ?? 0);
                    if (inventoryId != 0)
                    {
                        txtVehicleAltInventoryId.Text = inventoryId.ToString();
                    }
                    EnableEditForVehicleAllotment();
                }
            }

            ////Populate Finance Allotment
            if (vclBooking.FinanceAllotmentId != 0)
            {
                txtFinanceAllotmentId.Text = vclBooking.FinanceAllotmentId.ToString();
                if (txtFinanceAllotmentId.Text != "")
                {
                    EnableEditForFinanceAllotment();
                }
            }

            //Populate Insurance Allotment
            if (vclBooking.InsuranceAllotmentId != 0)
            {
                txtInsuranceAllotmentId.Text = vclBooking.InsuranceAllotmentId.ToString();
                if (txtInsuranceAllotmentId.Text != "")
                {
                    EnableEditForInsuranceAllotment();
                }
            }

            // Populate RTO Allotment
            if (vclBooking.RTOAllotmentId != 0)
            {
                txtIRTOAllotmentId.Text = vclBooking.RTOAllotmentId.ToString();
                if (txtIRTOAllotmentId.Text != "")
                {
                    EnableEditForRTOAllotment();
                }
            }

            //Populate Spare Parts Allotment
            SparePartsAllotmentBL obj = new SparePartsAllotmentBL();
            var lst = obj.GetSparePartsAllotmentbyBookingId(vehicleBookingId);

            lstSPaltid = new List <int>();
            if (lst.Count > 0)
            {
                string spAltId = "";
                foreach (var alt in lst)
                {
                    lstSPaltid.Add(alt.SparePartsBookingAllotmentID);
                    spAltId = spAltId + alt.SparePartsBookingAllotmentID + "__" + alt.SparePartsInventoryID + "&&";
                }
                txtIRTOAllotmentId.Text = spAltId;
                EnableEditForSPAllotment();
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtCustomerName.Text == "" || ddlEmployees.SelectedIndex == -1 || ddlModel.SelectedIndex == -1 || txtDealerRemark.Text == "" || ddlStatus.SelectedIndex == -1 || (!rdnPayCash.Checked && !rdnPayFinance.Checked))
            {
                MyMessageBox.ShowBox("Please enter all Mandatory Fields !!!");
                return;
            }

            //ReadyToDeliver
            bool flgRTOD = false;

            if (rdnRtoDYes.Checked)
            {
                flgRTOD = true;
                string result = MyMessageBoxYesorNo.ShowBox("Are you sure to Deliver the Vehicles?  Please validate Vehicle, Spare Parts, Insurance, Finance and RTO is Alloted");
                if (result != "1")
                {
                    return;
                }
            }

            //Get Sales Executive Id
            int SalesExecutiveId = 0;

            if (ddlEmployees.SelectedIndex != -1)
            {
                var salesItem = (ComboboxItem)ddlEmployees.SelectedItem;
                SalesExecutiveId = Convert.ToInt32(salesItem.Value);
            }


            int Model = 0;

            if (ddlModel.SelectedIndex != -1)
            {
                var modelItem = (ComboboxItem)ddlModel.SelectedItem;
                Model = Convert.ToInt32(modelItem.Value);
            }

            //Get StatusId
            int StatusId = 0;

            if (ddlStatus.SelectedIndex != -1)
            {
                var statusitem = (ComboboxItem)ddlStatus.SelectedItem;
                StatusId = Convert.ToInt32(statusitem.Value);
            }



            //AdvanceAmountMode
            bool flgAdvCash = false;

            if (rdnAdvCash.Checked)
            {
                flgAdvCash = true;
            }

            //CashOrFinance
            bool flagCash = false;

            if (rdnPayCash.Checked)
            {
                flagCash = true;
            }

            //FinancierId

            int?financierId = null;

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

            int?advanceChequeNo = null;

            if (txtChequeNo.Text != "")
            {
                advanceChequeNo = Convert.ToInt32(txtChequeNo.Text);
            }

            //Populate VehicleBookingDTO
            VehicleBookingDTO dto = new VehicleBookingDTO()
            {
                CustomerID          = Convert.ToInt32(txtCustomerId.Text),
                VehicleEnquiryID    = _vehicleEnquiryId,
                ReferenceBy         = txtReferenceBy.Text,
                SalesExecutiveId    = SalesExecutiveId,
                ModelID             = Model,
                Color1              = ddlColor1.Text,
                Color2              = ddlColor2.Text,
                Color3              = ddlColor3.Text,
                CustomerRemark      = txtCustomerRemark.Text,
                ClosingRemark       = txtDealerRemark.Text,
                ReadyToDeliver      = flgRTOD,
                AdvanceAmount       = Convert.ToInt32(txtAdvanceAmount.Text),
                AdvanceMode         = flgAdvCash,
                AdvanceChequeNo     = advanceChequeNo ?? 0,
                IsCash              = flagCash,
                FinancierInfoId     = financierId,
                FinancierRemark     = txtFinanceRemark.Text,
                StatusId            = StatusId,
                FollowupDescription = txtDealerRemark.Text,
                FollowupIsActive    = true,
                FollowupDate        = Convert.ToDateTime(dtFollowupDate.Text),
                CommittedDate       = Convert.ToDateTime(dtCommittedDate.Text),
                CreatedBy           = GlobalSetup.Userid,
                CreatedDate         = DateTime.Now,
                ModifiedBy          = GlobalSetup.Userid,
                ModifiedDate        = DateTime.Now
            };

            if (_mode == "EDIT" || _mode == "DELIVERY")
            {
                dto.VehicleBookingID = _vehicleBookingId;
            }
            //Save VehicleBooking
            VehicleBookingBL bl = new VehicleBookingBL();
            var flag            = bl.SaveVehicleBooking(dto, _mode);

            if (flag)
            {
                MyMessageBox.ShowBox("Vehicle Booking Saved");
                Clear();
                this.Close();
            }
            else
            {
                MyMessageBox.ShowBox("Vehicle Booking Failed to Save");
            }
        }
Beispiel #3
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);
        }