public Modulo GetOne(string desc) { Modulo modulo = new Modulo(); try { this.OpenConnection(); SqlCommand cmdGetOne = new SqlCommand("GetOne_Modulos", SqlConn); cmdGetOne.CommandType = CommandType.StoredProcedure; cmdGetOne.Parameters.Add("@desc", SqlDbType.VarChar).Value = desc; SqlDataReader drModulos = cmdGetOne.ExecuteReader(); while (drModulos.Read()) { modulo.ID = (int)drModulos["id_modulo"]; modulo.Descripcion = (string)drModulos["desc_modulo"]; //modulo.Ejecuta = (string)drModulos["ejecuta"]; } drModulos.Close(); } catch (Exception e) { Exception ExcepcionManejada = new Exception("Error al recuperar datos de los Modulos", e); throw ExcepcionManejada; } finally { this.CloseConnection(); } return modulo; }
public List<Modulo> GetAll() { List<Modulo> modulos = new List<Modulo>(); try { this.OpenConnection(); SqlCommand cmdGetAll = new SqlCommand("GetAll_Modulos", SqlConn); cmdGetAll.CommandType = CommandType.StoredProcedure; SqlDataReader drModulos = cmdGetAll.ExecuteReader(); while (drModulos.Read()) { Modulo mod = new Modulo(); mod.ID = (int)drModulos["id_modulo"]; mod.Descripcion = (string)drModulos["desc_modulo"]; mod.Ejecuta = (string)drModulos["ejecuta"]; modulos.Add(mod); } drModulos.Close(); } catch (Exception e) { Exception ExcepcionManejada = new Exception("Error al recuperar datos de los Modulos", e); throw ExcepcionManejada; } finally { this.CloseConnection(); } return modulos; }
public ModuloDesktop(int ID, ModoForm modo) : this() { Modo = modo; Business.Logic.ModuloLogic ml = new ModuloLogic(); ModuloActual = ml.GetOne(ID); MapearDeDatos(); }
public void Save(Modulo mod) { if (mod.State == BusinessEntity.States.New) { Modulos.Add(mod); } else if (mod.State == BusinessEntity.States.Deleted) { this.Delete(mod.Descripcion); } else if (mod.State == BusinessEntity.States.Modified) { Modulos[Modulos.FindIndex(delegate(Modulo m) { return m.Descripcion == mod.Descripcion; })] = mod; } }
public override void MapearADatos() { if (Modo == AplicationForm.ModoForm.Alta) { Business.Entities.Modulo m = new Business.Entities.Modulo(); ModuloActual = m; this.txtDescripcion.Text = this.ModuloActual.Descripcion; this.txtEjecuta.Text = this.ModuloActual.Ejecuta; } else if (Modo == AplicationForm.ModoForm.Modificacion) { this.ModuloActual.ID = Convert.ToInt32(this.txtID.Text); this.ModuloActual.Descripcion = this.txtDescripcion.Text; this.ModuloActual.Ejecuta = this.txtEjecuta.Text; } }
public virtual void MapearADatos() { Business.Entities.Modulo moduloActual = this.DevolverModulo(); Business.Entities.Usuario usuarioActual = this.DevolverUsuario(); switch (this.Modo) { case (ModoForm.Alta): { ModuloUsrActual = new ModuloUsuario(); this.ModuloUsrActual.IdUsuario = usuarioActual.ID; this.ModuloUsrActual.IdModulo = moduloActual.ID; this.ModuloUsrActual.PermiteAlta = this.chkAlta.Checked; this.ModuloUsrActual.PermiteBaja = this.chkBaja.Checked; this.ModuloUsrActual.PermiteConsulta = this.chkConsulta.Checked; this.ModuloUsrActual.PermiteModificacion = this.chkMod.Checked; this.ModuloUsrActual.State = BusinessEntity.States.New; break; } case (ModoForm.Modificacion): { this.ModuloUsrActual.IdUsuario = usuarioActual.ID; this.ModuloUsrActual.IdModulo = moduloActual.ID; this.ModuloUsrActual.PermiteAlta = this.chkAlta.Checked; this.ModuloUsrActual.PermiteBaja = this.chkBaja.Checked; this.ModuloUsrActual.PermiteConsulta = this.chkConsulta.Checked; this.ModuloUsrActual.PermiteModificacion = this.chkMod.Checked; this.ModuloUsrActual.State = BusinessEntity.States.Modified; break; } case (ModoForm.Baja): { this.ModuloUsrActual.State = BusinessEntity.States.Deleted; break; } case (ModoForm.Consulta): { this.ModuloUsrActual.State = BusinessEntity.States.Unmodified; break; } } }
public List<Modulo> GetAll() { List<Modulo> modulos = new List<Modulo>(); try { this.OpenConnection(); SqlCommand cmdModulos = new SqlCommand("select * from modulos", sqlConn); SqlDataReader drModulos = cmdModulos.ExecuteReader(); while (drModulos.Read()) { Modulo m = new Modulo(); m.ID = (int)drModulos["id_modulo"]; m.Descripcion=(String)drModulos["desc_modulo"]; m.Ejecuta = (String)drModulos["Ejecuta"]; modulos.Add(m); } drModulos.Close(); } catch (Exception Ex) { Exception ExcepcionManejada = new Exception("Error al recuperar lista de modulos", Ex); throw ExcepcionManejada; } finally { this.CloseConnection(); } return modulos; }
public Modulo GetOne(int ID) { Modulo m = new Modulo(); try { this.OpenConnection(); SqlCommand cmdModulos = new SqlCommand("SELECT * from modulos where id_modulo=@id", sqlConn); cmdModulos.Parameters.Add("@id", SqlDbType.Int).Value = ID; SqlDataReader drModulos = cmdModulos.ExecuteReader(); if (drModulos.Read()) { m.ID = (int)drModulos["id_modulo"]; m.Descripcion = (String)drModulos["desc_modulo"]; m.Ejecuta = (String)drModulos["ejecuta"]; } drModulos.Close(); } catch (Exception Ex) { Exception ExcepcionManejada = new Exception("Error al recuperar datos del modulo", Ex); throw ExcepcionManejada; } finally { this.CloseConnection(); } return m; }
public void Save(Business.Entities.Modulo modulo) { ModuloData.Save(modulo); }
protected void Update(Modulo modulo) { try { this.OpenConnection(); SqlCommand cmdSave = new SqlCommand( "UPDATE modulos SET desc_modulo=@desc_modulo, ejecuta=@ejecuta" + "WHERE id_modulo=@id", sqlConn); cmdSave.Parameters.Add("@id", SqlDbType.Int).Value = modulo.ID; cmdSave.Parameters.Add("@desc_modulo", SqlDbType.VarChar, 50).Value = modulo.Descripcion; cmdSave.Parameters.Add("@ejecuta", SqlDbType.VarChar, 50).Value = modulo.Ejecuta; cmdSave.ExecuteNonQuery(); } catch (Exception Ex) { Exception ExcepcionManejeada = new Exception("Error al modificar modulo", Ex); throw ExcepcionManejeada; } finally { this.CloseConnection(); } }
protected void Insert(Modulo modulo) { try { this.OpenConnection(); SqlCommand cmdSave = new SqlCommand( "insert into modulos(desc_modulo,ejecuta)" + "values (@desc_modulo, @ejecuta)" + "select @@identity", sqlConn); cmdSave.Parameters.Add("@desc_modulo", SqlDbType.VarChar, 50).Value = modulo.Descripcion; cmdSave.Parameters.Add("@ejecuta", SqlDbType.VarChar, 50).Value = modulo.Ejecuta; modulo.ID = Decimal.ToInt32((decimal)cmdSave.ExecuteScalar()); } catch (Exception Ex) { Exception ExcepcionManejeada = new Exception("Error al crear modulos", Ex); throw ExcepcionManejeada; } finally { this.CloseConnection(); } }
public void Save(Modulo modulo) { if (modulo.State == BusinessEntity.States.Deleted) { this.Delete(modulo.ID); } else if (modulo.State == BusinessEntity.States.New) { this.Insert(modulo); } else if (modulo.State == BusinessEntity.States.Modified) { this.Update(modulo); } modulo.State = BusinessEntity.States.Unmodified; }
public void Save( Modulo Modulo) { ModuloData.Save(Modulo); }