Exemple #1
0
 public bool UpdateDriverStatus(DriverData driver)
 {
     cmd             = new SqlCommand("proc_UpdateDriversStatus", con);
     cmd.CommandType = CommandType.StoredProcedure;
     try
     {
         cmd.Parameters.AddWithValue("@eId", driver.Id);
         cmd.Parameters.AddWithValue("@eStatus", driver.Status);
         if (con.State == ConnectionState.Open)
         {
             con.Close();
         }
         con.Open();
         int result = cmd.ExecuteNonQuery();
         if (result > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         con.Close();
     }
 }
Exemple #2
0
        public ICollection <DriverData> SelectAllDrivers()
        {
            List <DriverData> drivers = new List <DriverData>();
            SqlCommand        cmd     = new SqlCommand("proc_GetAllDrivers", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter daDriver = new SqlDataAdapter(cmd);
            DataSet        ds       = new DataSet();//collection of datatables

            try
            {
                daDriver.Fill(ds, "Driver");
                DriverData driver;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    driver        = new DriverData();
                    driver.Id     = Convert.ToInt32(dr[0]);
                    driver.Name   = dr[1].ToString();
                    driver.Phone  = dr[2].ToString();
                    driver.Status = dr[3].ToString();
                    driver.Area   = dr[3].ToString();
                    drivers.Add(driver);
                }
                return(drivers);
            }
            catch (Exception e)
            {
                throw e;
            }
        }