private void BtnActualizar_Click(object sender, EventArgs e) { try { if (this.validacionImgError()) { this.convertir(); EParte Obj = new EParte(); Obj.parteID = Convert.ToInt32(this.txtId.Text); Obj.nombre = this.txtNombre.Text.Trim(); NParte.update(Obj); this.MostrarDB(); this.LimpiarPRegistro(); } else { throw new Exception("Datos Obligatorios"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Sistema Odontograma"); } }
public static long save(EParte Parte) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <parte> partes = new List <parte>(); parte Obj = new parte(); partes = (from t in cn.parte where t.nombre == Parte.nombre select t).ToList(); if (partes.Count > 0) { throw new Exception("El Parte Ya Existe"); } Obj.nombre = Parte.nombre; cn.parte.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.parteID); } else { throw new Exception("Error al guardar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EParte> mostrar(string texto) { try { List <EParte> Partes = new List <EParte>(); List <parte> partes = new List <parte>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { partes = (from t in cn.parte where t.estado == 1 where t.nombre.Contains(texto) orderby t.parteID descending select t).ToList(); foreach (var item in partes) { EParte Obj = new EParte(); Obj.parteID = item.parteID; Obj.nombre = item.nombre; Obj.estado = item.estado; Partes.Add(Obj); } return(Partes); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { this.convertir(); EParte Obj = new EParte(); Obj.nombre = this.txtNombre.Text.Trim(); NParte.save(Obj); this.LimpiarPRegistro(); this.MostrarDB(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Sistema de Odontograma Guardar"); } }
private void DataListado_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataListado.Columns["Eliminar"].Index) { DialogResult Opcion; Opcion = MessageBox.Show("Realmente desea Eliminar El Registro", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { string Codigo; string Rpta = ""; Codigo = Convert.ToString(this.dataListado.CurrentRow.Cells["parteID"].Value); EParte Obj = new EParte(); Obj.parteID = Convert.ToInt32(Codigo); Rpta = Convert.ToString(NParte.delete(Obj)); if (Rpta.Equals("OK")) { this.MensajeOk("Se ELimino Correctamente el Registro"); } else { this.MensajeError(Rpta); } this.MostrarDB(); } } else { if (e.ColumnIndex == dataListado.Columns["Editar"].Index) { this.txtId.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["parteID"].Value); this.txtNombre.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["nombre"].Value); this.OcultarPRegistro(false, false); this.lbModificar.Visible = true; this.lbAgregar.Visible = false; } } }
public static string delete(EParte Parte) { string rpta = ""; try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); parte Obj = new parte(); //Obj = (from p in cn.paciente // where p.id == Paciente.id // select p).First(); Obj = cn.parte.Find(Parte.parteID); cn.SaveChanges(); } catch (Exception ex) { rpta = (ex.Message); } return(rpta); }
public static long update(EParte Parte) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <parte> partes = new List <parte>(); parte Obj = new parte(); partes = (from t in cn.parte where t.nombre == Parte.nombre select t).ToList(); if (partes.Count > 0) { throw new Exception("El parte Ya Existe"); } Obj = (from t in cn.parte where t.parteID == Parte.parteID select t).First(); Obj.nombre = Parte.nombre; int result = cn.SaveChanges(); if (result > 0) { return(Obj.parteID); } else { throw new Exception("No Hubo Ningun Cambio al Editar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }