public E_materia obtenerDatosMat(int cod) { E_materia obj = db.materias.Where(val => val.codigo == cod).Select(val => new E_materia() { _codigo = val.codigo, _nombre = val.nombreM, _usuarioEmple = val.usuarioEmple }).FirstOrDefault(); return(obj); }
private void insercion(object sender, EventArgs e, int numero) { try { E_materia _mat = new E_materia(); int resp = -1; bool _resul = false; bool _estado = false; #region validaciones foreach (char item in txt_nomMateria.Text) { if (char.IsDigit(item)) { _resul = false; _estado = true; break; } } if (_estado) { error1.SetError(txt_nomMateria, "El nombre de la materia no puede contener numeros."); } else { error1.Clear(); _resul = true; } #endregion if (_resul) { _mat._codigo = Convert.ToInt32(msk_codMateria.Text); _mat._nombre = txt_nomMateria.Text; _mat._usuarioEmple = txt_codProfMat.Text; resp = _proceMenu.insertaMateria(_mat, numero); if (resp == 1) { MessageBox.Show("Guardado."); G_menuAdmin_Load(sender, e); msk_codMateria.Text = ""; txt_nomMateria.Text = ""; txt_codProfMat.Text = ""; } else { MessageBox.Show("No se a logrado guardar."); } } } catch (Exception ex) { MessageBox.Show("No se a logrado guardar."); } }
private void btn_busMatM_Click(object sender, EventArgs e) { try { E_materia _mat = new E_materia(); _mat = _matricula.ObtenerMat(Convert.ToInt32(txt_busMatM.Text)); if (_mat == null) { MessageBox.Show("No existe el registro."); } else { txt_codMatM.Text = _mat._codigo.ToString(); txt_nomMatM.Text = _mat._nombre; txt_usuProfM.Text = _mat._usuarioEmple; } } catch (Exception) { MessageBox.Show("No existe el registro."); } }
public int mantenimientoMateria(E_materia mat, int num) { try { materia _mat = new materia(); var resp = (from dato in db.empleados where dato.usuario == mat._usuarioEmple select dato.rol).FirstOrDefault(); if (resp.ToString() == "2") { if (num != -1) { _mat = db.materias.Where(val => val.codigo == mat._codigo).Single <materia>(); } _mat.codigo = mat._codigo; _mat.nombreM = mat._nombre; _mat.usuarioEmple = mat._usuarioEmple; if (num == -1) { _mat.estado = 1; db.materias.InsertOnSubmit(_mat); } db.SubmitChanges(); return(1); } else { return(0); } } catch (Exception ex) { return(0); } }
public int insertaMateria(E_materia mat, int numero) { return(_DMat.mantenimientoMateria(mat, numero)); }