Exemplo n.º 1
0
    protected void grdCarsInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string vehicalNum = ((Label)grdCarsInfo.Rows[e.RowIndex].FindControl("lblVNumberEdit")).Text;
        string manufacturer = ((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtManufacturer")).Text;
        string make = ((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtMake")).Text;
        int capacity = Convert.ToInt32(((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtCapacity")).Text);
        string color = ((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtColor")).Text;
        int userId = Convert.ToInt32(Session["userid"]);

        CarDetailsEntity cdetails = new CarDetailsEntity { VehicleNumber = vehicalNum, Manufacturer = manufacturer, Make = make, Capacity = capacity, Color = color, Owner = userId };
        dalRegisteredCars.UpdateCarDetails(cdetails);
        grdCarsInfo.EditIndex = -1;
        FillGrdCarDetails(userId);
    }
Exemplo n.º 2
0
    protected void grdCarsInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string vehicalNum   = ((Label)grdCarsInfo.Rows[e.RowIndex].FindControl("lblVNumberEdit")).Text;
        string manufacturer = ((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtManufacturer")).Text;
        string make         = ((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtMake")).Text;
        int    capacity     = Convert.ToInt32(((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtCapacity")).Text);
        string color        = ((TextBox)grdCarsInfo.Rows[e.RowIndex].FindControl("txtColor")).Text;
        int    userId       = Convert.ToInt32(Session["userid"]);

        CarDetailsEntity cdetails = new CarDetailsEntity {
            VehicleNumber = vehicalNum, Manufacturer = manufacturer, Make = make, Capacity = capacity, Color = color, Owner = userId
        };

        dalRegisteredCars.UpdateCarDetails(cdetails);
        grdCarsInfo.EditIndex = -1;
        FillGrdCarDetails(userId);
    }
Exemplo n.º 3
0
    /*************************************************************************************
    * Method Name      :  UpdateCarDetails
    * Return Value     :  void
    * Input Parameters :  CarDetails
    * Description      :  This method is used to update registered car details for a owner
    *************************************************************************************/
    public void UpdateCarDetails(CarDetailsEntity carInfo)
    {
        SqlCommand cmdUpdateCarDetails = new SqlCommand("usp_UpdateCarInfo", Con);
        cmdUpdateCarDetails.CommandType = CommandType.StoredProcedure;

        cmdUpdateCarDetails.Parameters.AddWithValue("@VehicleNumber", carInfo.VehicleNumber);
        cmdUpdateCarDetails.Parameters.AddWithValue("@Manufacturer", carInfo.Manufacturer);
        cmdUpdateCarDetails.Parameters.AddWithValue("@Make", carInfo.Make);
        cmdUpdateCarDetails.Parameters.AddWithValue("@Owner", carInfo.Owner);
        cmdUpdateCarDetails.Parameters.AddWithValue("@Color", carInfo.Color);
        cmdUpdateCarDetails.Parameters.AddWithValue("@Capacity", carInfo.Capacity);

        try
        {
            Con.Open();
            cmdUpdateCarDetails.ExecuteNonQuery();

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            Con.Close();
        }
    }