Beispiel #1
0
        public task_location Select(int id)
        {
            task_location task_location    = new task_location();
            string        ConnectionString = IDManager.connection();
            SqlConnection con = new SqlConnection(ConnectionString);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_TASK_LOCATION", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@task_loc_id", id);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    rdr.Read();
                    if (!rdr.IsDBNull(0))
                    {
                        task_location.task_loc_id = rdr.GetInt32(0);
                    }
                    else
                    {
                        task_location.task_loc_id = 0;
                    }
                    if (!rdr.IsDBNull(1))
                    {
                        task_location.task_id = rdr.GetInt32(1);
                    }
                    else
                    {
                        task_location.task_id = 0;
                    }
                    if (!rdr.IsDBNull(2))
                    {
                        task_location.task_loc_description = rdr.GetString(2);
                    }
                    else
                    {
                        task_location.task_loc_description = " ";
                    }
                }
                else
                {
                    task_location.SetColumnDefaults();
                }
            }
            catch (Exception ex)
            {
                task_location.SetColumnDefaults();
                return(task_location);
            }
            finally
            {
                con.Close();
            }
            return(task_location);
        }
Beispiel #2
0
        public task_location Insert(task_location id)
        {
            string        ConnectionString = IDManager.connection();
            SqlConnection con = new SqlConnection(ConnectionString);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_TASK_LOCATION", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@task_id", id.task_id);
                cmd.Parameters.AddWithValue("@task_loc_description", id.task_loc_description);
                cmd.ExecuteReader();
                con.Close();
                con.Open();
                cmd             = new SqlCommand("SP_DMCS_GET_TASK_LOCATION", con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@task_id", id.task_id);
                cmd.Parameters.AddWithValue("@task_loc_description", id.task_loc_description);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    rdr.Read();
                    id.task_loc_id = rdr.GetInt32(0);
                }
            }
            catch (Exception ex)
            {
                id.SetColumnDefaults();
            }
            finally
            {
                con.Close();
            }
            return(id);
        }
 public task_location Select(int id)
 {
     task_location task_location = new task_location();
     string ConnectionString = IDManager.connection();
     SqlConnection con = new SqlConnection(ConnectionString);
     try
     {
     con.Open();
     SqlCommand cmd = new SqlCommand("SP_DMCS_SELECT_TASK_LOCATION", con);
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@task_loc_id", id);
     SqlDataReader rdr = cmd.ExecuteReader();
     if (rdr.HasRows)
     {
         rdr.Read();
         if (!rdr.IsDBNull(0))
         {
             task_location.task_loc_id = rdr.GetInt32(0);
         }
         else
         {
             task_location.task_loc_id = 0;
         }
         if (!rdr.IsDBNull(1))
         {
             task_location.task_id = rdr.GetInt32(1);
         }
         else
         {
             task_location.task_id = 0;
         }
         if (!rdr.IsDBNull(2))
         {
             task_location.task_loc_description = rdr.GetString(2);
         }
         else
         {
             task_location.task_loc_description = " ";
         }
         }
         else
         {
             task_location.SetColumnDefaults();
         }
     }
     catch (Exception ex)
     {
     task_location.SetColumnDefaults();
     return task_location;
     }
     finally
     {
     con.Close();
     }
     return task_location;
 }
 public task_location Insert(task_location id)
 {
     string ConnectionString = IDManager.connection();
     SqlConnection con = new SqlConnection(ConnectionString);
     try
     {
     con.Open();
     SqlCommand cmd = new SqlCommand("SP_DMCS_INSERT_TASK_LOCATION", con);
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@task_id", id.task_id);
     cmd.Parameters.AddWithValue("@task_loc_description", id.task_loc_description);
     cmd.ExecuteReader();
     con.Close();
     con.Open();
     cmd = new SqlCommand("SP_DMCS_GET_TASK_LOCATION", con);
     cmd.CommandType = System.Data.CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@task_id", id.task_id);
     cmd.Parameters.AddWithValue("@task_loc_description", id.task_loc_description);
     SqlDataReader rdr = cmd.ExecuteReader();
     if (rdr.HasRows)
     {
         rdr.Read();
         id.task_loc_id = rdr.GetInt32(0);
     }
     }
     catch (Exception ex)
     {
     id.SetColumnDefaults();
     }
     finally
     {
     con.Close();
     }
     return id;
 }