public static long save(EAtencion Atencion) { try { using (dbodontogramaEntity cn = new dbodontogramaEntity()) { atencion Obj = new atencion(); Obj.pacienteID = Atencion.pacienteID; Obj.empleadoID = Atencion.empleadoID; Obj.odontologoID = Atencion.odontologoID; Obj.fecha = Convert.ToDateTime(DateTime.Now.ToLongDateString()); Obj.hora = Atencion.hora; Obj.importe = Atencion.importe; Obj.descripcion = Atencion.descripcion; Obj.estado = 1; cn.atencion.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.atencionID); } else { throw new Exception("Error Al guardar El Registro"); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void BtnActualizar_Click(object sender, EventArgs e) { try { if (this.validacionImgError()) { this.convertir(); EAtencion Obj = new EAtencion(); Obj.atencionID = Convert.ToInt32(this.txtId.Text); Obj.pacienteID = Convert.ToInt32(this.txtidpaciente.Text); Obj.odontologoID = Convert.ToInt32(this.txtIdOdontologo.Text); Obj.empleadoID = empleado.usuarioID; Obj.hora = this.txtHora.Value.TimeOfDay; Obj.importe = Convert.ToDecimal(this.txtImporte.Text); Obj.descripcion = this.txtDescripcion.Text.Trim(); Obj.tipo = this.tipo; NAtencion.update(Obj); this.MostrarDB(); this.LimpiarPRegistro(); } else { throw new Exception("Datos Obligatorios"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Sistema Odontograma"); } }
//expresiones Landan y Delegados //user Control public static string delete(EAtencion Atencion) { string rpta = ""; try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); atencion Obj = new atencion(); Obj = cn.atencion.Find(Atencion.atencionID); rpta = Obj.estado == 1 ? "OK" : "No se Puede Eliminar el Registro"; Obj.estado = 0; cn.SaveChanges(); } catch (Exception ex) { rpta = (ex.Message); } return(rpta); }
public static List <EAtencion> mostrarReporteAtencionRango(DateTime inicio, DateTime fin) { try { List <EAtencion> Atencions = new List <EAtencion>(); List <atencion> atencions = new List <atencion>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { atencions = (from p in cn.atencion where p.estado == 1 where p.fecha >= inicio.Date && p.fecha <= fin.Date select p).ToList(); foreach (var item in atencions) { EAtencion Obj = new EAtencion(); Obj.atencionID = item.atencionID; Obj.pacienteID = item.pacienteID; Obj.empleadoID = item.empleadoID; Obj.odontologoID = item.odontologoID; Obj.fecha = item.fecha; Obj.hora = item.hora; Obj.importe = item.importe; Obj.tipo = item.tipo; Obj.descripcion = item.descripcion; Obj.Odontologo = item.odontologo.nombre + " " + item.odontologo.apellido; Obj.Paciente = item.paciente.nombre + " " + item.paciente.apellido; Obj.Empleado = item.empleado.nombre + " " + item.empleado.apellido; Obj.estado = item.estado; Atencions.Add(Obj); } return(Atencions); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long update(EAtencion Atencion) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <atencion> atencions = new List <atencion>(); atencion Obj = new atencion(); if (atencions.Count > 1) { throw new Exception("El atencion Ya Existe"); } Obj = (from p in cn.atencion where p.atencionID == Atencion.atencionID select p).First(); Obj.pacienteID = Atencion.pacienteID; Obj.empleadoID = Atencion.empleadoID; Obj.odontologoID = Atencion.odontologoID; Obj.fecha = Convert.ToDateTime(DateTime.Now.ToLongDateString()); Obj.hora = Atencion.hora; Obj.importe = Atencion.importe; Obj.descripcion = Atencion.descripcion; Obj.estado = 1; int result = cn.SaveChanges(); if (result > 0) { return(Obj.atencionID); } else { throw new Exception("No hubo Ningun Cambio al Editar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public EAtencion mostrarAtencionID(int ID) { try { EAtencion Obj = new EAtencion(); atencion item = new atencion(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { item = (from p in cn.atencion where p.estado == 1 where p.atencionID == ID select p).First(); Obj.atencionID = item.atencionID; Obj.pacienteID = item.pacienteID; Obj.empleadoID = item.empleadoID; Obj.odontologoID = item.odontologoID; Obj.fecha = item.fecha; Obj.hora = item.hora; Obj.tipo = item.tipo; Obj.importe = item.importe; Obj.descripcion = item.descripcion; Obj.Odontologo = item.odontologo.nombre + " " + item.odontologo.apellido; Obj.Paciente = item.paciente.nombre + " " + item.paciente.apellido; Obj.Empleado = item.empleado.nombre + " " + item.empleado.apellido; Obj.estado = item.estado; return(Obj); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long update(EOdontograma Odontograma, DataTable dtDetalles, EAtencion atencion, EPaciente paciente, EUsers odontologo, EUsers empleado) { int result = 0; CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); var db = cn.Database.BeginTransaction(); try { odontograma Obj = new odontograma(); Obj = cn.odontograma.Find(Odontograma.odontogramaID); Obj.fechaFinal = Convert.ToDateTime(DateTime.Now.ToLongDateString()); Obj.odontogramaID = Odontograma.odontogramaID; Obj.tratamiento = Odontograma.tratamiento; Obj.montoTotal = Odontograma.montoTotal; Obj.estado = 1; result = cn.SaveChanges(); List <odontograma_detalle> ODT = new List <odontograma_detalle>(); ODT = (from od in cn.odontograma_detalle where od.odontogramaID == Odontograma.odontogramaID select od).ToList(); foreach (var item in ODT) { odontograma_detalle ODTF = new odontograma_detalle(); ODTF = (from dt in cn.odontograma_detalle where dt.odontogramaID == Odontograma.odontogramaID && dt.dienteID == item.dienteID && dt.procedimientoID == item.procedimientoID && dt.diagnosticoID == item.diagnosticoID && dt.parteID == item.parteID select dt).First(); ODTF.estado = 0; cn.SaveChanges(); } foreach (DataRow row in dtDetalles.Rows) { odontograma_detalle OD = new odontograma_detalle(); OD.odontogramaID = Obj.odontogramaID; OD.dienteID = Convert.ToInt32(row["dienteID"].ToString()); OD.diagnosticoID = Convert.ToInt32(row["diagnosticoID"].ToString()); OD.procedimientoID = Convert.ToInt32(row["procedimientoID"].ToString()); OD.parteID = Convert.ToInt32(row["parteID"].ToString()); List <odontograma_detalle> ODL = new List <odontograma_detalle>(); ODL = (from dt in cn.odontograma_detalle where dt.odontogramaID == OD.odontogramaID && dt.dienteID == OD.dienteID && dt.diagnosticoID == OD.diagnosticoID && dt.procedimientoID == OD.procedimientoID && dt.parteID == OD.parteID select dt).ToList(); if (ODL.Count > 0) { OD = (from od in cn.odontograma_detalle where od.odontogramaID == Obj.odontogramaID && od.diagnosticoID == OD.diagnosticoID && od.procedimientoID == OD.procedimientoID && od.dienteID == OD.dienteID && od.parteID == OD.parteID select od).First(); OD.realizado = Convert.ToString(row["realizado"].ToString()); OD.estado = 1; } else { OD.realizado = Convert.ToString(row["realizado"].ToString()); OD.estado = 1; cn.odontograma_detalle.Add(OD); } result = cn.SaveChanges() + result; } atencion atencionR = new atencion(); atencionR.fecha = Convert.ToDateTime(DateTime.Now.ToLongDateString()); atencionR.hora = DateTime.Now.TimeOfDay; atencionR.importe = atencion.importe; atencionR.descripcion = atencion.descripcion; atencionR.estado = 1; atencionR.tipo = "TRATAMIENTO"; atencionR.pacienteID = paciente.pacienteID; atencionR.odontologoID = odontologo.usuarioID; atencionR.empleadoID = empleado.usuarioID; cn.atencion.Add(atencionR); result = cn.SaveChanges() + result; int contador = 0; foreach (DataRow row in dtDetalles.Rows) { if (Convert.ToString(row["realizado"].ToString()) == "SI") { atencion_detalle atencionD = new atencion_detalle(); atencionD.atencionID = atencionR.atencionID; atencionD.odontogramaID = Obj.odontogramaID; atencionD.dienteID = Convert.ToInt32(row["dienteID"].ToString()); atencionD.diagnosticoID = Convert.ToInt32(row["diagnosticoID"].ToString()); atencionD.procedimientoID = Convert.ToInt32(row["procedimientoID"].ToString()); atencionD.parteID = Convert.ToInt32(row["parteID"].ToString()); List <atencion_detalle> cd = new List <atencion_detalle>(); cd = (from dt in cn.atencion_detalle where dt.estado == 1 where dt.odontogramaID == atencionD.odontogramaID && dt.dienteID == atencionD.dienteID && dt.diagnosticoID == atencionD.diagnosticoID && dt.procedimientoID == atencionD.procedimientoID && dt.parteID == atencionD.parteID select dt).ToList(); if (cd.Count == 0) { contador++; atencionD.realizado = Convert.ToString(row["realizado"].ToString()); atencionD.estado = 1; cn.atencion_detalle.Add(atencionD); result = cn.SaveChanges() + result; } } } if (result > 0 && contador != 0) { db.Commit(); return(atencionR.atencionID); } else { db.Rollback(); throw new Exception("Error al guardar"); } } catch (Exception ex) { db.Rollback(); throw new Exception(ex.Message); } }
public static long save(EOdontograma Odontograma, DataTable dtDetalles, EAtencion atencion, EPaciente paciente, EUsers odontologo, EUsers empleado) { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); var db = cn.Database.BeginTransaction(); try { odontograma Obj = new odontograma(); Obj.fechaInicio = Convert.ToDateTime(DateTime.Now.ToLongDateString()); Obj.fechaFinal = Convert.ToDateTime(DateTime.Now.ToLongDateString()); Obj.estado = 1; Obj.tratamiento = Odontograma.tratamiento; Obj.montoTotal = Odontograma.montoTotal; cn.odontograma.Add(Obj); int result = cn.SaveChanges(); foreach (DataRow row in dtDetalles.Rows) { odontograma_detalle OD = new odontograma_detalle(); OD.odontogramaID = Obj.odontogramaID; OD.dienteID = Convert.ToInt32(row["dienteID"].ToString()); OD.diagnosticoID = Convert.ToInt32(row["diagnosticoID"].ToString()); OD.procedimientoID = Convert.ToInt32(row["procedimientoID"].ToString()); OD.parteID = Convert.ToInt32(row["parteID"].ToString()); OD.realizado = Convert.ToString(row["realizado"].ToString()); OD.estado = 1; cn.odontograma_detalle.Add(OD); result = cn.SaveChanges() + result; } atencion atencionR = new atencion(); atencionR.fecha = Convert.ToDateTime(DateTime.Now.ToLongDateString()); atencionR.hora = DateTime.Now.TimeOfDay; atencionR.importe = atencion.importe; atencionR.descripcion = atencion.descripcion; atencionR.estado = 1; atencionR.tipo = "TRATAMIENTO"; atencionR.pacienteID = paciente.pacienteID; atencionR.odontologoID = odontologo.usuarioID; atencionR.empleadoID = empleado.usuarioID; cn.atencion.Add(atencionR); result = cn.SaveChanges() + result; int contador = 0; foreach (DataRow row in dtDetalles.Rows) { if (Convert.ToString(row["realizado"].ToString()) == "SI") { contador++; atencion_detalle atencionD = new atencion_detalle(); atencionD.atencionID = atencionR.atencionID; atencionD.odontogramaID = Obj.odontogramaID; atencionD.dienteID = Convert.ToInt32(row["dienteID"].ToString()); atencionD.diagnosticoID = Convert.ToInt32(row["diagnosticoID"].ToString()); atencionD.procedimientoID = Convert.ToInt32(row["procedimientoID"].ToString()); atencionD.parteID = Convert.ToInt32(row["parteID"].ToString()); atencionD.realizado = Convert.ToString(row["realizado"].ToString()); atencionD.estado = 1; cn.atencion_detalle.Add(atencionD); result = cn.SaveChanges() + result; } } if (result > 0 && contador != 0) { db.Commit(); return(atencionR.atencionID); } else { db.Rollback(); throw new Exception("Error al guardar"); } } catch (Exception ex) { db.Rollback(); throw new Exception(ex.Message); } }
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["atencionID"].Value); EAtencion Obj = new EAtencion(); Obj.atencionID = Convert.ToInt32(Codigo); Rpta = Convert.ToString(NAtencion.delete(Obj)); if (Rpta.Equals("OK")) { this.MensajeOk("Se ELimino Correctamente el Registro"); } else { this.MensajeError(Rpta); } this.MostrarDB(); } } if (e.ColumnIndex == dataListado.Columns["Editar"].Index) { this.LimpiarPRegistro(); this.txtId.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["atencionID"].Value); this.txtidpaciente.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["pacienteID"].Value); this.txtIdOdontologo.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["odontologoID"].Value); this.txtpaciente.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["paciente"].Value); this.txtOdontologo.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["odontologo"].Value); this.txtEmpleado.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["empleado"].Value); this.txtHora.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["hora"].Value); this.txtDescripcion.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["descripcion"].Value); this.txtImporte.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["importe"].Value); this.tipo = Convert.ToString(this.dataListado.CurrentRow.Cells["tipo"].Value); if (this.tipo == "consulta") { this.chConsulta.Checked = true; } else { this.chTratamiento.Checked = true; } ///LOCA this.OcultarPRegistro(false, false); this.lbModificar.Visible = true; this.lbAgregar.Visible = false; this.txtidpaciente.Visible = false; this.txtIdOdontologo.Visible = false; } if (e.ColumnIndex == dataListado.Columns["imprimir"].Index) { } }