Esempio n. 1
0
 public Boolean EliminarSucursal(Sucursal Sucursal)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(strConnection))
         {
             conn.Open();
             SqlCommand command = new SqlCommand("USP_ELIMINAR_SUCURSAL", conn);
             command.CommandType = CommandType.StoredProcedure;
             command.Connection  = conn;
             command.Parameters.AddWithValue("@Id", Sucursal.Id);
             command.ExecuteNonQuery();
             conn.Close();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 2
0
 public Boolean InsertarSucursal(Sucursal Sucursal)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(strConnection))
         {
             conn.Open();
             SqlCommand command = new SqlCommand("USP_INSERTAR_SUCURSAL", conn);
             command.CommandType = CommandType.StoredProcedure;
             command.Connection  = conn;
             command.Parameters.AddWithValue("@Nombre", Sucursal.Nombre);
             command.Parameters.AddWithValue("@Direccion", Sucursal.Direccion);
             command.Parameters.AddWithValue("@FechaRegistro", Sucursal.FechaRegistro);
             command.Parameters.AddWithValue("@IdBanco", Sucursal.IdBanco);
             command.ExecuteNonQuery();
             conn.Close();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 3
0
        public Sucursal ObtenerPorId(int Id)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(strConnection))
                {
                    conn.Open();
                    SqlCommand command = new SqlCommand("USP_OBTENER_SUCURSAL_ID", conn);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Connection  = conn;
                    command.Parameters.AddWithValue("@Id", Id);
                    //List<Banco> lstBanco = new List<Banco>();
                    IDataReader lector     = command.ExecuteReader();
                    Sucursal    beSucursal = null;
                    while (lector.Read())
                    {
                        beSucursal = new Sucursal()
                        {
                            Id            = lector.GetInt32(0),
                            Nombre        = lector.GetString(1),
                            Direccion     = lector.GetString(2),
                            FechaRegistro = lector.GetDateTime(3),
                            IdBanco       = lector.GetInt32(4),
                        };
                        // lstBanco.Add(beBanco);
                    }

                    conn.Close();
                    return(beSucursal);//lstBanco;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }