public VehicleInventoryDTO GetVehicleInventory(int InventoryId)
        {
            VehicleInventoryDTO voIDTO = new VehicleInventoryDTO();

            try
            {
                using (var entities = new ManiMotorsEntities1())
                {
                    voIDTO = (from invlist in entities.VehicleInventories
                              join invstatus in entities.VehicleInventoryStatus
                              on invlist.VehicleInventoryID equals invstatus.VehicleInventoryID
                              join vehinfo in entities.VehicleInfoes
                              on invlist.VehicleInfoID equals vehinfo.VehicleInfoID
                              join vehStatus in entities.VehicleInventoryStatus
                              on invlist.VehicleInventoryID equals vehStatus.VehicleInventoryID
                              join vehStatusTypes in entities.VehicleInventoryStatusTypes
                              on vehStatus.VehicleInventoryStatusTypeID equals vehStatusTypes.VehicleInventoryStatusTypeID
                              where invlist.VehicleInventoryID == InventoryId
                              select new VehicleInventoryDTO
                    {
                        VehicleInventoryID = invlist.VehicleInventoryID,
                        VehicleInfoID = invlist.VehicleInfoID,
                        VehicleModelName = vehinfo.ModelName,
                        VehicleModelCode = vehinfo.ModelCode,
                        ChasisNo = invlist.ChasisNo,
                        EngineNo = invlist.EngineNo,
                        Color = invlist.Color,
                        MfgDate = invlist.ManfgDate ?? DateTime.Now,
                        ServiceBookNo = invlist.ServiceBookNo,
                        KeyNo = invlist.KeyNo,
                        BatteryMake = invlist.BatteryMake,
                        BatteryNo = invlist.BatteryNo,
                        VehicleInventoryStatusTypeID = vehStatusTypes.VehicleInventoryStatusTypeID,
                        VehicleInventoryStatusName = vehStatusTypes.Description,
                        Is50PerMarginPrice = invlist.Is50PercentMarginPrice ?? false,
                        Is70PerMarginPrice = invlist.Is70PercentMarginPrice ?? false,
                        IsMarginPrice = invlist.IsMarginPrice ?? false,
                        ExShowRoomPrice = invlist.ExShowroomPrice ?? 0,
                        LT_RT_OtherExp = invlist.LT_RT_OtherExp ?? 0,
                        InsurancePrice = invlist.InsurancePrice ?? 0,
                        OnRoadPrice = invlist.OnRoadPrice ?? 0,
                        MarginPrice = invlist.MarginPrice ?? 0,
                        Margin50 = invlist.CreditPercentMargin ?? 0,
                        Margin70 = invlist.FullCashPercentMargin ?? 0,
                        WarrantyPrice = invlist.WarrantyPrice ?? 0
                    }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(voIDTO);
        }
Example #2
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();
        }
        public bool SaveInventoryVehicle(VehicleInventoryDTO dto, string mode)
        {
            var flag = false;

            try
            {
                using (var entities = new ManiMotorsEntities1())
                {
                    if (mode == "EDIT")
                    {
                        var info = entities.VehicleInventories.FirstOrDefault(v => v.VehicleInventoryID == dto.VehicleInventoryID);
                        info.VehicleInfoID          = dto.VehicleInfoID;
                        info.ChasisNo               = dto.ChasisNo;
                        info.EngineNo               = dto.EngineNo;
                        info.Color                  = dto.Color;
                        info.ManfgDate              = dto.MfgDate;
                        info.ServiceBookNo          = dto.ServiceBookNo;
                        info.KeyNo                  = dto.KeyNo;
                        info.BatteryMake            = dto.BatteryMake;
                        info.BatteryNo              = dto.BatteryNo;
                        info.CreatedDate            = dto.CreatedDate;
                        info.Createdby              = dto.CreatedBy;
                        info.ModifiedDate           = dto.ModifiedDate;
                        info.Modifiedby             = dto.ModifiedBy;
                        info.IsMarginPrice          = dto.IsMarginPrice;
                        info.Is50PercentMarginPrice = dto.Is50PerMarginPrice;
                        info.Is70PercentMarginPrice = dto.Is70PerMarginPrice;
                        info.ExShowroomPrice        = dto.ExShowRoomPrice;
                        info.LT_RT_OtherExp         = dto.LT_RT_OtherExp;
                        info.InsurancePrice         = dto.InsurancePrice;
                        info.OnRoadPrice            = dto.OnRoadPrice;
                        info.MarginPrice            = dto.MarginPrice;
                        info.CreditPercentMargin    = dto.Margin50;
                        info.FullCashPercentMargin  = dto.Margin70;
                        info.WarrantyPrice          = dto.WarrantyPrice;
                        entities.SaveChanges();

                        var invInfo = entities.VehicleInventoryStatus.FirstOrDefault(vi => vi.VehicleInventoryID == dto.VehicleInventoryID);
                        if (invInfo != null)
                        {
                            invInfo.VehicleInventoryStatusTypeID = dto.VehicleInventoryStatusTypeID;
                            invInfo.Remarks      = dto.Remarks;
                            invInfo.Modifiedby   = dto.ModifiedBy;
                            invInfo.ModifiedDate = dto.ModifiedDate;
                            entities.SaveChanges();
                        }
                        flag = true;
                    }
                    else
                    {
                        VehicleInventory info = new VehicleInventory()
                        {
                            VehicleInfoID          = dto.VehicleInfoID,
                            ChasisNo               = dto.ChasisNo,
                            EngineNo               = dto.EngineNo,
                            Color                  = dto.Color,
                            ManfgDate              = dto.MfgDate,
                            ServiceBookNo          = dto.ServiceBookNo,
                            KeyNo                  = dto.KeyNo,
                            BatteryNo              = dto.BatteryNo,
                            BatteryMake            = dto.BatteryMake,
                            CreatedDate            = dto.CreatedDate,
                            Createdby              = dto.CreatedBy,
                            ModifiedDate           = dto.ModifiedDate,
                            Modifiedby             = dto.ModifiedBy,
                            IsMarginPrice          = dto.IsMarginPrice,
                            Is50PercentMarginPrice = dto.Is50PerMarginPrice,
                            Is70PercentMarginPrice = dto.Is70PerMarginPrice,
                            ExShowroomPrice        = dto.ExShowRoomPrice,
                            LT_RT_OtherExp         = dto.LT_RT_OtherExp,
                            InsurancePrice         = dto.InsurancePrice,
                            OnRoadPrice            = dto.OnRoadPrice,
                            MarginPrice            = dto.MarginPrice,
                            CreditPercentMargin    = dto.Margin50,
                            FullCashPercentMargin  = dto.Margin70,
                            WarrantyPrice          = dto.WarrantyPrice,
                        };
                        entities.VehicleInventories.Add(info);
                        entities.SaveChanges();
                        VehicleInventoryStatu obj = new VehicleInventoryStatu();
                        obj.VehicleInventoryID           = info.VehicleInventoryID;
                        obj.VehicleInventoryStatusTypeID = dto.VehicleInventoryStatusTypeID;//InStock Status
                        obj.Remarks = dto.Remarks;
                        entities.VehicleInventoryStatus.Add(obj);
                        entities.SaveChanges();
                        flag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }
Example #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);
        }