public void eliminarPuesto(CatPuestos _catpuestos) { try { using (SqlCommand command = new SqlCommand("SPD_CAT_PUESTOS_DEL", cn.Connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@iIdPuesto", _catpuestos.iIdPuesto); cn.OpenConnection(); command.ExecuteNonQuery(); } } catch (SqlException ex) { throw new Exception("No se pudo eliminar el registro del puesto" + ex.Message); } catch (Exception ex) { throw new Exception("No se pudo eliminar el registro del puesto" + ex.Message); } finally { cn.CloseConnection(); } }
public int insertarPuesto(CatPuestos _catpuestos) { int id = 0; try { using (SqlCommand command = new SqlCommand("SPD_CAT_PUESTOS_INS", cn.Connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@cNombre", _catpuestos.cNombre); command.Parameters.AddWithValue("@iIdUsuarioGestion", _catpuestos.iIdUsuarioGestion); cn.OpenConnection(); id = (int)command.ExecuteScalar(); } } catch (SqlException ex) { throw new Exception("No se pudo insertar el registro del puesto" + ex.Message); } catch (Exception ex) { throw new Exception("No se pudo insertar el registro del puesto" + ex.Message); } finally { cn.CloseConnection(); } return(id); }
public void modificarPuesto(CatPuestos _catpuestos) { try { using (SqlCommand command = new SqlCommand("spd_cat_puestos_upd", cn.Connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@idpuesto", _catpuestos.idpuesto); command.Parameters.AddWithValue("@descripcion", _catpuestos.descripcion); cn.OpenConnection(); command.ExecuteNonQuery(); } } catch (SqlException ex) { throw new Exception("No se pudo modificar el registro del puesto" + ex.Message); } catch (Exception ex) { throw new Exception("No se pudo modificar el registro del puesto" + ex.Message); } finally { cn.CloseConnection(); } }
protected void Editar_Click(object sender, EventArgs e) { if (txtDescripcionEditar.Text == String.Empty) { lblMensajeEditar.Visible = true; upModalEditar.Update(); } else { if (Catalogo.Value == "Departamentos") { _catdepartamento = new CatDepartamentos(); _catdepartamento.iddepto = Convert.ToInt32(ID.Value.ToString()); _catdepartamento.descripcion = txtDescripcionEditar.Text; _catdepneg.modificarDepartamento(_catdepartamento); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEditar", "$('#ModalEditar').modal('hide');", true); upModalEditar.Update(); GridViewDepartamentos.DataSource = _catdepneg.list(); GridViewDepartamentos.DataBind(); } if (Catalogo.Value == "Sedes") { _catsede = new CatSedes(); _catsede.idsede = Convert.ToInt32(ID.Value.ToString()); _catsede.descripcion = txtDescripcionEditar.Text; _catsedneg.modificarSede(_catsede); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEditar", "$('#ModalEditar').modal('hide');", true); upModalEditar.Update(); GridViewSedes.DataSource = _catsedneg.list(); GridViewSedes.DataBind(); } if (Catalogo.Value == "Puestos") { _catpuesto = new CatPuestos(); _catpuesto.idpuesto = Convert.ToInt32(ID.Value.ToString()); _catpuesto.descripcion = txtDescripcionEditar.Text; _catpuesneg.modificarPuesto(_catpuesto); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEditar", "$('#ModalEditar').modal('hide');", true); upModalEditar.Update(); GridViewPuestos.DataSource = _catpuesneg.list(); GridViewPuestos.DataBind(); } if (Catalogo.Value == "Temas") { _cattema = new CatTemas(); _cattema.idtema = Convert.ToInt32(ID.Value.ToString()); _cattema.descripcion = txtDescripcionEditar.Text; _cattemneg.modificarTema(_cattema); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEditar", "$('#ModalEditar').modal('hide');", true); upModalEditar.Update(); GridViewTemas.DataSource = _cattemneg.list(); GridViewTemas.DataBind(); } } }
public void eliminarPuesto(CatPuestos _catpuestos) { try { CatPuestosDAL _catpuestosDAL = new CatPuestosDAL(); _catpuestosDAL.eliminarPuesto(_catpuestos); }catch (Exception ex) { throw new Exception(ex.Message); } }
public int insertarPuesto(CatPuestos _catpuestos) { try { CatPuestosDAL _catpuestosDAL = new CatPuestosDAL(); return(_catpuestosDAL.insertarPuesto(_catpuestos)); } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void Nuevo_Click(object sender, EventArgs e) { if (txtDescripcionNuevo.Text == String.Empty) { lblMensajeNuevo.Visible = true; upModalNuevo.Update(); } else { if (Catalogo.Value == "Departamentos") { _catdepartamento = new CatDepartamentos(); _catdepartamento.descripcion = txtDescripcionNuevo.Text; _catdepneg.insertarDepartamento(_catdepartamento); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalNuevo", "$('#ModalNuevo').modal('hide');", true); upModalNuevo.Update(); GridViewDepartamentos.DataSource = _catdepneg.list(); GridViewDepartamentos.DataBind(); } if (Catalogo.Value == "Sedes") { _catsede = new CatSedes(); _catsede.descripcion = txtDescripcionNuevo.Text; _catsedneg.insertarSede(_catsede); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalNuevo", "$('#ModalNuevo').modal('hide');", true); upModalNuevo.Update(); GridViewSedes.DataSource = _catsedneg.list(); GridViewSedes.DataBind(); } if (Catalogo.Value == "Puestos") { _catpuesto = new CatPuestos(); _catpuesto.descripcion = txtDescripcionNuevo.Text; _catpuesneg.insertarPuesto(_catpuesto); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalNuevo", "$('#ModalNuevo').modal('hide');", true); upModalNuevo.Update(); GridViewPuestos.DataSource = _catpuesneg.list(); GridViewPuestos.DataBind(); } if (Catalogo.Value == "Temas") { _cattema = new CatTemas(); _cattema.descripcion = txtDescripcionNuevo.Text; _cattemneg.insertarTema(_cattema); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalNuevo", "$('#ModalNuevo').modal('hide');", true); upModalNuevo.Update(); GridViewTemas.DataSource = _cattemneg.list(); GridViewTemas.DataBind(); } } }
protected void Eliminar_Click(object sender, EventArgs e) { if (Catalogo.Value == "Departamentos") { _catdepartamento = new CatDepartamentos(); _catdepartamento.iddepto = Convert.ToInt32(ID.Value.ToString()); _catdepneg.eliminarDepartamento(_catdepartamento); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEliminar", "$('#ModalEliminar').modal('hide');", true); upModalEliminar.Update(); GridViewDepartamentos.DataSource = _catdepneg.list(); GridViewDepartamentos.DataBind(); } if (Catalogo.Value == "Sedes") { _catsede = new CatSedes(); _catsede.idsede = Convert.ToInt32(ID.Value.ToString()); _catsedneg.eliminarSede(_catsede); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEliminar", "$('#ModalEliminar').modal('hide');", true); upModalEliminar.Update(); GridViewSedes.DataSource = _catsedneg.list(); GridViewSedes.DataBind(); } if (Catalogo.Value == "Puestos") { _catpuesto = new CatPuestos(); _catpuesto.idpuesto = Convert.ToInt32(ID.Value.ToString()); _catpuesneg.eliminarPuesto(_catpuesto); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEliminar", "$('#ModalEliminar').modal('hide');", true); upModalEliminar.Update(); GridViewPuestos.DataSource = _catpuesneg.list(); GridViewPuestos.DataBind(); } if (Catalogo.Value == "Temas") { _cattema = new CatTemas(); _cattema.idtema = Convert.ToInt32(ID.Value.ToString()); _cattemneg.eliminarTema(_cattema); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalEliminar", "$('#ModalEliminar').modal('hide');", true); upModalEliminar.Update(); GridViewTemas.DataSource = _cattemneg.list(); GridViewTemas.DataBind(); } }
public List <CatPuestos> obtenerPuestos(string filtro = null) { List <CatPuestos> list = new List <CatPuestos>(); CatPuestos cat; try { using (SqlCommand command = new SqlCommand("SPD_CATALOGOS_GET", cn.Connection)) { command.CommandType = CommandType.StoredProcedure; //command.Parameters.AddWithValue("@idpuesto", id == 0 ? (object)DBNull.Value : id); command.Parameters.AddWithValue("@tipo", "puestos"); command.Parameters.AddWithValue("@filtro", string.IsNullOrEmpty(filtro) ? (object)DBNull.Value : filtro); cn.OpenConnection(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { cat = new CatPuestos(); cat.iIdPuesto = (int)reader["iIdPuesto"]; cat.cNombre = (string)reader["cNombre"]; cat.dtFechaRegistro = (DateTime)reader["dtFechaRegistro"]; list.Add(cat); } } } catch (SqlException ex) { throw new Exception("No se pudo obtener registros del catalogo de puestos" + ex.Message); } catch (Exception ex) { throw new Exception("No se pudo obtener registros del catalogo de puestos" + ex.Message); } finally { cn.CloseConnection(); } return(list); }