private void btnBuscar_Click(object sender, EventArgs e) { GeneralerrorProvider.Clear(); if (Validar(1)) { MessageBox.Show("Ingrese un ID"); return; } int id = Convert.ToInt32(GrupoIdnumericUpDown.Value); Grupos grupo = BLL.GruposBLL.Buscar(id); if (grupo != null) { GrupoIdnumericUpDown.Value = grupo.GrupoId; descripcionTextBox.Text = grupo.Descripcion; CantidadnumericUpDown.Value = grupo.Cantidad; GDeseadosnumericUpDown.Value = grupo.GruposDeseados; } else { MessageBox.Show("No se encontro!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEliminar_Click(object sender, EventArgs e) { try { int Index = this.dtgGrupos.CurrentRow.Index; DialogResult Resp = MessageBox.Show("¿Desea Eliminar el Registro?", "ADVERTENCIA", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (Resp == DialogResult.Yes) { //PRIMER PASO, CREACION DE OBJETO Grupos Modelo = new Grupos(); // SEGUNDO PASO SINCRONIZAR INTERFAZ GRAFICA CON EL OBJETO Modelo.IDGrupo = this.dtgGrupos.Rows[Index].Cells["IDGrupo"].Value.ToString(); if (Modelo.Eliminar()) { MessageBox.Show("Registro Eliminado correctamente", "Confirmacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Registro no fue Eliminado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception exc) { MessageBox.Show("Registro Inválido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } CargarGrupos(); }
internal List <Grupos> GetGrupos() { List <Grupos> GruposList = new List <Grupos>(); SqlCommand sqlCommand = new SqlCommand(); SqlParameterCollection parametros = sqlCommand.Parameters; DataTable dtUsuario = Dao.ConsultaInformacion("getGRUPOS", parametros); if (dtUsuario.Rows.Count > 0) { foreach (DataRow dr in dtUsuario.Rows) { Grupos Grupos = new Grupos(); Grupos.IdGrupo = Convert.ToInt32(dr["IdGrupo"]); Grupos.Nombre = dr["Nombre"].ToString(); Grupos.NombreCarrera = dr["NombreCarrera"].ToString(); Grupos.IdCarrera = Convert.ToInt32(dr["IdCarrera"].ToString()); GruposList.Add(Grupos); } } return(GruposList); }
public IHttpActionResult PostGrupos(Grupos grupos) { grupos.IdGrupo = Guid.NewGuid(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Grupos.Add(grupos); try { db.SaveChanges(); return(Ok(grupos)); } catch (DbUpdateException) { if (GruposExists(grupos.IdGrupo)) { return(Conflict()); } else { throw; } } }
public Grupos obtenerGrupo(int idGrupo) { try { Grupos gr = new Grupos(); var query = from c in entities.Grupos where c.idGrupo == idGrupo select c; List <Grupos> grupos = query.ToList <Grupos>(); foreach (Grupos grupo in grupos) { if (grupo.idGrupo == idGrupo) { gr = grupo; } } return(gr); } catch (Exception ex) { throw ex; } }
//GRUPOS-CARRERA internal List <Grupos> GetGruposByCarrera(int IdCarrera) { List <Grupos> GruposList = new List <Grupos>(); SqlCommand sqlCommand = new SqlCommand(); SqlParameterCollection parametros = sqlCommand.Parameters; parametros.Add("@IdCarrera", SqlDbType.Int).Value = IdCarrera; DataTable dtGrupos = Dao.ConsultaInformacion("getGRUPOSCARRERA", parametros); if (dtGrupos.Rows.Count > 0) { foreach (DataRow dr in dtGrupos.Rows) { Grupos Grupos = new Grupos(); Grupos.IdGrupo = Convert.ToInt32(dr["IdGrupo"]); Grupos.Nombre = dr["Nombre"].ToString(); Grupos.NombreCarrera = dr["NombreCarrera"].ToString(); Grupos.IdCarrera = Convert.ToInt32(dr["IdCarrera"].ToString()); GruposList.Add(Grupos); } } return(GruposList); }
public static Grupos Buscar(int id) { Contexto contexto = new Contexto(); Grupos Grupo = new Grupos(); try { Grupo = contexto.Grupo.Find(id); Grupo.Detalle.Count(); foreach (var item in Grupo.Detalle) { string s = item.Persona.Nombres; } contexto.Dispose(); } catch (Exception) { throw; } return(Grupo); }
private void GuardarButton_Click(object sender, EventArgs e) { bool paso = false; if (Validar()) { MessageBox.Show("Complete estos campos", "Errores", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Grupos grupos = LlenaClase(); //Si va a guardar o modificar if (GrupoiIdNumericUpDown.Value == 0) { paso = BLL.GruposBLL.Guardar(grupos); } else { paso = BLL.GruposBLL.Modificar(grupos); } //Si se Guardó o no if (paso) { MessageBox.Show("Guardado!!", "Correcto!!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se guardó!!", "Falló", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static bool Modificar(Grupos Grupo) { bool paso = false; Contexto contexto = new Contexto(); try { foreach (var item in Grupo.Detalle) { var estado = item.Id > 0 ? EntityState.Modified : EntityState.Added; contexto.Entry(item).State = estado; } contexto.Entry(Grupo).State = EntityState.Modified; if (contexto.SaveChanges() > 0) { paso = true; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
private void BindGrid() { var listaGrupos = new Grupos().RetornaTodos(); grdGrupos.DataSource = listaGrupos.ToList(); grdGrupos.DataBind(); }
public Grupos getById(Grupos a) { grupo = null; try { conexion.Cmd.Connection.Open(); conexion.Cmd.CommandText = "sp_GrupoIdNew "; conexion.Cmd.Parameters.Clear(); conexion.Cmd.Parameters.Add(new SqlParameter("Id", a.GrupoID)); conexion.Cmd.Parameters.Add(new SqlParameter("Salon", 1)); conexion.Cmd.Parameters.Add(new SqlParameter("SucursalID", a.SucursalID)); conexion.Cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = conexion.Cmd.ExecuteReader(); if (dr.HasRows) { grupo = mapearObjeto(dr); } dr.Close(); conexion.Cmd.Connection.Close(); } catch (SqlException ex) { conexion.Cmd.Connection.Close(); Logger.Log(ex.Message); } return(grupo); }
public void GuardarTest() { /*bool paso = false; * Grupos grupo = new Grupos(); * grupo.GrupoId = 2; * grupo.Descripcion = "Mate"; * grupo.Cantidad = 30; * grupo.Grupo = 2; * grupo.Integrantes = 15; * * paso = BLL.GruposBLL.Guardar(grupo); * * Assert.AreEqual(paso,true);*/ Grupos grupo = new Grupos { Fecha = DateTime.Now, Comentarios = "Me Encanto" }; grupo.Detalle.Add(new GruposDetalle(0, 0, 1)); bool paso = BLL.GruposBLL.Guardar(grupo); Assert.AreEqual(true, paso); }
/// <summary> /// Nos permite Eliminar un grupo de estudiante /// </summary> /// <param name="id"></param> /// <returns>retorna true si elimino y false sino</returns> public static bool Eliminar(int id) { bool paso = false; Contexto contexto = new Contexto(); try { Grupos grupo = contexto.Grupos.Find(id); contexto.Grupos.Remove(grupo); if (contexto.SaveChanges() > 0) { paso = true; } } catch (Exception) { throw; } finally { contexto.Dispose(); } return(paso); }
private void ListadoEstado() { cbEstado.DataSource = Grupos.ListarEstado(); cbEstado.DisplayMember = "ESTADO"; cbEstado.ValueMember = "ID_ESTADO"; cbEstado.SelectedIndex = -1; }
private Grupos LlenaClase() { Grupos Grupo = new Grupos(); Grupo.GrupoId = Convert.ToInt32(GrupoIDnumericUpDown.Value); Grupo.Fecha = FechadateTimePicker.Value; Grupo.Descripcion = DescripciontextBox.Text; Grupo.grupos = Convert.ToInt32(GruposnumericUpDown.Value); Grupo.Cantidad = Convert.ToInt32(CantidadnumericUpDown.Value); Grupo.Integrantes = Convert.ToInt32(IntegrantesnumericUpDown.Value); Grupo.Comentarios = ComentariostextBox.Text; foreach (DataGridViewRow item in DetalledataGridView.Rows) { Grupo.AgregarDetalle( ToInt(item.Cells["Id"].Value), ToInt(item.Cells["GrupoId"].Value), ToInt(item.Cells["PersonaId"].Value), ToInt(item.Cells["Cargo"].Value), ToInt(item.Cells["Cantidad"].Value) ); } return(Grupo); }
public static bool Modificar(Grupos grupos) { bool paso = false; Contexto contexto = new Contexto(); try { //todo: buscar las entidades que no estan para removerlas //recorrer el detalle foreach (var item in grupos.Detalle) { //Muy importante indicar que pasara con la entidad del detalle var estado = item.Id > 0 ? EntityState.Modified : EntityState.Added; contexto.Entry(item).State = estado; } //Idicar que se esta modificando el encabezado contexto.Entry(grupos).State = EntityState.Modified; if (contexto.SaveChanges() > 0) { paso = true; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
private void Guardar_button_Click(object sender, EventArgs e) { bool paso = false; Grupos grupo = LlenaClase(); if (Validar()) { if (grupoIdNumericUpDown.Value == 0) { paso = BLL.GruposBLL.Guardar(grupo); } else { paso = BLL.GruposBLL.Modificar(grupo); } if (paso) { MessageBox.Show("Guardado Correctamente", "Exito Al Guardar!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No Se Pudo Guardar", "Fallo Al Guardar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public void BuscarTest() { Grupos grupo = new Grupos(); grupo = GruposBLL.Buscar(8); Assert.IsNotNull(grupo); }
public static Grupos Buscar(int id) { Grupos grupos = new Grupos(); Contexto contexto = new Contexto(); try { grupos = contexto.Grupos.Find(id); //Cargar la lista en este punto porque //luego de hacer Dispose() el Contexto //no sera posible leer la lista grupos.Detalle.Count(); //Cargar los nombres de las personas foreach (var item in grupos.Detalle) { //forzando la persona a cargarse string s = item.Persona.Nombres; } contexto.Dispose(); } catch (Exception) { throw; } return(grupos); }
public ActionResult Create(GruposViewModel model) { if (ModelState.IsValid) { var grupo = new Grupos(); grupo.Nome = model.Nome; grupo.Nu_parcelas = model.Nu_parcelas; grupo.Tipo_adesao = model.Tipo_adesao; grupo.Dt_Vencimento = model.Dt_Vencimento; grupo.Dt_Cadastro = DateTime.Today; grupo.Ano = "1"; grupo.Dia = "1"; grupo.Mes = "1"; // Salvar a imagem para a pasta e pega o caminho db.Grupos.Add(grupo); db.SaveChanges(); //return RedirectToAction("Create", "Contrato", new { id=cliente.ClienteId}); return(RedirectToAction("Index")); } // Se ocorrer um erro retorna para pagina return(View(model)); }
public List <Grupos> GetGrupos(ComboBox combo) { var listgrupos = new List <Grupos>(); //la variable var es generica var ds = new DataSet(); string consulta = "Select * from grupos"; ds = conexion.Obtenerdatos(consulta, "grupos"); combo.DataSource = ds.Tables[0]; combo.DisplayMember = "grupo"; var dt = new DataTable(); dt = ds.Tables[0]; foreach (DataRow row in dt.Rows) { //string datos = string.Format("{0}", row.ItemArray[0]); //combo.Items.Add(datos); var grupos = new Grupos { Idgrupo = Convert.ToInt32(row["Idgrupo"]), Grupo = row["grupo"].ToString(), }; listgrupos.Add(grupos); } //lenar lista return(listgrupos); }
public ActionResult DeleteConfirmed(int id) { Grupos grupos = db.Grupos.Find(id); db.Grupos.Remove(grupos); db.SaveChanges(); return RedirectToAction("Index"); }
private void Buscarbutton_Click(object sender, EventArgs e) { GeneralerrorProvider.Clear(); if (Validar(1)) { MessageBox.Show("Ingrese un ID"); return; } int id = Convert.ToInt32(IdnumericUpDown.Value); Grupos grupos = BLL.GruposBLL.Buscar(id); if (grupos != null) { DescripciontextBox.Text = grupos.Descripcion; FechadateTimePicker.Text = grupos.Fecha.ToString(); CantidadnumericUpDown.Value = grupos.Cantidad; GruposnumericUpDown.Value = grupos.Grupo; IntegrantesnumericUpDown.Value = grupos.Integrantes = (grupos.Cantidad / grupos.Grupo); } else { MessageBox.Show("No se encontro", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Buscar_Click(object sender, EventArgs e) // BOTON BUSCAR { ErrorProvider.Clear(); if (Validar(1)) { MessageBox.Show("Ingrese el ID del Grupo"); return; } int id = Convert.ToInt32(GrupoIdUpDown.Value); Grupos grupo = BLL.GruposBLL.Buscar(id); if (grupo != null) { GrupoIdUpDown.Value = grupo.GrupoId; descripcionTextBox.Text = grupo.Descripcion; CantidadUpDown.Value = grupo.Cantidad; GruposDUpDown.Value = grupo.CantGrupos; } else { MessageBox.Show("No se encontro!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult Form(int?id, Operaciones operaciones) { var grupos = new Grupos(); using (MyDbContext context = new MyDbContext()) { //crear instancia de la DAL y se pasa el contexto de la bd CarrerasDAL dal = new CarrerasDAL(context); MateriasDAL dal2 = new MateriasDAL(context); ProfesoresDAL dal3 = new ProfesoresDAL(context); //llamada al metodo para obtener todos los registros List <Carreras> lstCarreras = dal.obtenerTodos(); List <Materias> lstMaterias = dal2.obtenerTodos(); List <Profesores> lstProfesores = dal3.obtenerTodos(); ViewBag.Carreras = lstCarreras; ViewBag.Materias = lstMaterias; ViewBag.Profesores = lstProfesores; } //Si el id tiene un valor; entonces se procede a buscar una carrera if (id.HasValue) { grupos = servicio.obtenerPorId(id.Value); } ViewData["Operacion"] = operaciones; return(View(grupos)); }
public IHttpActionResult PutGrupos(int id, Grupos grupos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != grupos.GrupoId) { return(BadRequest()); } db.Entry(grupos).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GruposExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void ActualizarGrilla() { listaDeGrupos = Grupos.ObtenerGrupos(txtNumGrupo.Text); //meto el resultado en la grilla grillaGrupos.DataSource = listaDeGrupos; }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Grupos grupos = db.Grupos.Find(id); if (grupos == null) { return(HttpNotFound()); } var query = (from l in db.Asesores join p in db.Personas on l.id_asesor equals p.documento where l.id_asesor == grupos.id_lider select l.id_asesor + "-" + p.nombres + " " + p.apellidos ).FirstOrDefault(); //mirar si funciona ViewBag.id_lider = query; return(View(grupos)); }
private void LlenandoCombo() { grupo = new Grupos(); EstudiantecomboBox.DataSource = EstudiantesBLL.GetLista(); EstudiantecomboBox.ValueMember = "EstudianteId"; EstudiantecomboBox.DisplayMember = "Nombres"; }
private void dgvGroups_CellClick(object sender, DataGridViewCellEventArgs e) { try { int index = e.RowIndex; if (index >= 0) { List <Grupos> list = filterGroups.Count == 0 ? groups : filterGroups; selectedGroup = list[index]; HashSet <TotalSeccion> sections = (HashSet <TotalSeccion>)selectedGroup.TotalSeccions; TotalSeccion[] sectionsData = new TotalSeccion[sections.Count]; sections.CopyTo(sectionsData); loadSectionsTable(sectionsData); cmbDistricts.SelectedItem = selectedGroup.Distrito; cmbLocations.SelectedItem = selectedGroup.Localidade; txtGroup.Text = selectedGroup.grupoNum.ToString(); txtName.Text = selectedGroup.nombre; txtSchedule.Text = selectedGroup.horario; chbStatus.Checked = selectedGroup.baja; dtpFundation.Value = selectedGroup.fundacion; chbRegistration.Checked = selectedGroup.registrado; dtpRegistration.Value = selectedGroup.fechaRegistro; btnSaveModify.Text = "Modificar"; } } catch (Exception ex) { FormUtils.defaultErrorMessage(ex); } }
public GrupoController(Grupos grupos) { this.grupos = grupos; }
public BasicAuthenticationAttribute() { this.grupos = IoCWorker.Resolve<Grupos>(); this.usuarios = IoCWorker.Resolve<Usuarios>(); }
public UsuarioController(Grupos grupos, TrocaSenhaService lembraSenhaService) { this.grupos = grupos; this.lembraSenhaService = lembraSenhaService; }
public UsuarioController(Grupos grupos, TrocaSenhaService trocaSenhaService) { this.grupos = grupos; this.trocaSenhaService = trocaSenhaService; }
public GrupoHelper(Grupos grupos) { this.grupos = grupos; }
public AutenticaUsuarioService(Grupos grupos, Usuarios usuarios) { this.grupos = grupos; this.usuarios = usuarios; }