public bool Obtener(ref BE.Area beArea) { try { string sp = "SpTbAreaObtener"; SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@IDAREA", beArea.IdArea)); DataTable dt = new DataTable(); dad.Fill(dt); if ((dt.Rows.Count == 1)) { DataRow dr = dt.Rows[0]; Cargar(ref beArea, ref dr); } else { throw new Exception("No se pudo obtener el registro"); } return(true); } catch (Exception ex) { throw ex; } }
public List <BE.Area> ListarCombo() { List <BE.Area> lst = new List <BE.Area>(); try { var daArea = new DA.Area(); DataTable dt = daArea.Listar(new BE.Area() { Activo = true }); for (int i = 0; i < dt.Rows.Count; i++) { var dr = dt.Rows[i]; var beArea = new BE.Area(); daArea.Cargar(ref beArea, ref dr); lst.Add(beArea); } return(lst); } catch (Exception ex) { throw ex; } }
public void Cargar(ref BE.Area beArea, ref DataRow dr) { try { beArea.IdArea = dr["IdArea"] == DBNull.Value ? 0 : int.Parse(dr["IdArea"].ToString()); beArea.Nombre = dr["Nombre"] == DBNull.Value ? "" : dr["Nombre"].ToString(); beArea.Descripcion = dr["Descripcion"] == DBNull.Value ? "" : dr["Descripcion"].ToString(); beArea.Activo = dr["Activo"] == DBNull.Value ? false : bool.Parse(dr["Activo"].ToString()); } catch (Exception ex) { throw ex; } }
public BE.Area Obtener(int IdArea) { try { var beArea = new BE.Area(); beArea.IdArea = IdArea; if (new DA.Area().Obtener(ref beArea) == false) { beArea = null; } return(beArea); } catch (Exception ex) { throw ex; } }
public DataTable Listar(BE.Area beArea) { try { string sp = "SpTbAreaListar"; SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@ACTIVO", beArea.Activo)); DataTable dt = new DataTable(); dad.Fill(dt); return(dt); } catch (Exception ex) { throw ex; } }