private void bindLstVehicles()
        {
            ManageVehicle manageVehicle = new ManageVehicle();

            var lstVehicles = manageVehicle.getVehicleList(ConfigurationManager.ConnectionStrings["MVSSqlDev2008ConnectionString"].ConnectionString);
            lstVehicle.DataSource = lstVehicles;
            lstVehicle.DataTextField = lstVehicles.Columns["Stock_Code"].ToString();
            lstVehicle.DataValueField = lstVehicles.Columns["Stock_Code"].ToString();
            lstVehicle.DataBind();
        }
        protected void repeatVehicle_Load(object sender, EventArgs e)
        {
            if (ViewState["VehicleItems"] == null)
            {
                ManageVehicle vehicleObj = new ManageVehicle();
                var vehicleCatalogue = vehicleObj.getVehicleCatalogue(ConfigurationManager.ConnectionStrings["MVSSqlDev2008ConnectionString"].ConnectionString);
                ViewState.Add("VehicleItems", vehicleCatalogue);
                listViewVehicleCatalogue.DataSource = vehicleCatalogue;
                listViewVehicleCatalogue.DataBind();

            }
            else
            {
                listViewVehicleCatalogue.DataSource = ViewState["VehicleItems"];
                listViewVehicleCatalogue.DataBind();
            }
        }
        protected void btnSaveVehicle_ServerClick(object sender, EventArgs e)
        {
            VehicleObject obj = new VehicleObject();
            imageUtil = new ImageUtility();

            obj.AC = chkBoxAC.Checked;
            obj.Airbag = chkBoxAirbags.Checked;
            obj.AL = chkBoxAL.Checked;
            if (dateVehicleArrivalDate.Value != "")
            {
                obj.Arrival_Date = DateTime.ParseExact(dateVehicleArrivalDate.Value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
            }
            obj.Automatic_Transmission = chkBoxAL.Checked;
            obj.CD = chkBoxAL.Checked;
            obj.Chassis_Number = txtVehicleChassisNumber.Value;
            obj.CI = chkBoxCI.Checked;
            obj.Colour = txtVehicleColour.Value;
            obj.Condition = txtVehicleCondition.Value;
            obj.COR = chkBoxCOR.Checked;
            if (txtVehicleCostPrice.Value != "")
            {
                obj.Cost_Price = Convert.ToDecimal(txtVehicleCostPrice.Value);
            }
            obj.Engine_Number = txtVehicleEngineNumber.Value;
            obj.Extra_Features = txtVehicleExtraFeatures.Value;
            obj.FSH = chkBoxFSH.Checked;
            obj.Gearlock = chkBoxGearlock.Checked;
            obj.Leather = chkBoxLeather.Checked;
            obj.Location_Name = lstVehicleLocation.Value;
            obj.Mags = chkBoxMags.Checked;
            obj.Manufacturer_Name = lstVehicleManufacturerName.Value;
            if (txtVehicleMileage.Value != "")
            {
                obj.Mileage = Convert.ToInt32(txtVehicleMileage.Value);
            }
            obj.Model_Name = lstVehicleModelName.Value;
            obj.MP3 = chkBoxMP3.Checked;
            if (Session["Image1"] != null)
            {
                obj.Picture_1 = imageUtil.imageToByteArray(Session["Image1"].ToString());

            }
            if (Session["Image2"] != null)
            {
                obj.Picture_2 = imageUtil.imageToByteArray(Session["Image2"].ToString());
            }
            if (Session["Image3"] != null)
            {
                obj.Picture_3 = imageUtil.imageToByteArray(Session["Image3"].ToString());
            }
            obj.PS = chkBoxPS.Checked;
            obj.Registration_Number = txtVehicleRegistrationNumber.Value;
            if (txtVehicleRetailPrice.Value != "")
            {
                obj.Retail_Price = Convert.ToDecimal(txtVehicleRetailPrice.Value);
            }
            obj.RT = chkBoxRT.Checked;
            obj.Sports_Kit = chkBoxSportsKit.Checked;
            obj.SR = chkBoxSR.Checked;
            obj.Supplier_NameProp = lstVehicleSupplier.Value;
            obj.Vehicle_Status = lstVehicleStatus.Value;
            if (txtVehicleWholesalePrice.Value != "")
            {
                obj.Wholesale_Price = Convert.ToDecimal(txtVehicleWholesalePrice.Value);
            }

            ManageVehicle vehicleObj = new ManageVehicle();

            bool success = vehicleObj.updateAVehicle(ConfigurationManager.ConnectionStrings["MVSSqlDev2008ConnectionString"].ConnectionString,obj,(int)ViewState["id"]);

            if (success)
            {
                divSuccess.Visible = true;
            }
            else
                divFailure.Visible = true;
            imageUtil = null;
        }
        protected void btnSearch_ServerClick(object sender, EventArgs e)
        {
            try
            {
                if (txtSearchVehicles.Value.Length > 0)
                {
                    ManageVehicle manager = new ManageVehicle();
                    var vehicleList = manager.searchVehicle(ConfigurationManager.ConnectionStrings["MVSSqlDev2008ConnectionString"].ConnectionString, txtSearchVehicles.Value);
                    if (vehicleList != null && vehicleList.Rows.Count > 0)
                    {
                        nothingFound.Visible = false;
                        if (Session["SEARCH_VEHICLES"] != null)
                        {
                            Session.Remove("SEARCH_VEHICLES");
                        }
                        Session.Add("SEARCH_VEHICLES", vehicleList);
                        bindVehicles();
                    }
                    else
                    {
                        nothingFound.Visible = true;
                        grdVehicles.DataSource = null;
                        grdVehicles.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }