예제 #1
0
 private void BtnActualizar_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.validacionImgError())
         {
             this.convertir();
             EPaciente Obj = new EPaciente();
             Obj.pacienteID      = Convert.ToInt32(this.txtId.Text);
             Obj.nombre          = this.txtNombre.Text.Trim();
             Obj.apellido        = this.txtApellido.Text.Trim();
             Obj.telefono        = this.txtTelefono.Text.Trim();
             Obj.ci              = this.txtCI.Text.Trim();
             Obj.fechaNacimiento = Convert.ToDateTime(this.txtFecha.Text);
             Obj.direccion       = this.txtDireccion.Text.Trim();
             Obj.sexo            = this.sexo;
             NPacientes.update(Obj);
             this.MostrarDB();
             this.LimpiarPRegistro();
         }
         else
         {
             throw new Exception("Datos Obligatorios");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Sistema Odontograma");
     }
 }
예제 #2
0
        public EPaciente mostraPacienteOdontograma(int ID)
        {
            try
            {
                using (dbodontogramaEntity cn = new dbodontogramaEntity())
                {
                    paciente item = new paciente();
                    item = (from p in cn.paciente join c in cn.atencion on p.pacienteID equals c.pacienteID
                            join ct in cn.atencion_detalle on c.atencionID equals ct.atencionID
                            join od in cn.odontograma_detalle on ct.odontogramaID equals od.odontogramaID
                            join o in cn.odontograma on od.odontogramaID equals o.odontogramaID
                            where p.estado == 1 && o.odontogramaID == ID
                            select p).First();
                    EPaciente Obj = new EPaciente();
                    Obj.pacienteID      = item.pacienteID;
                    Obj.nombre          = item.nombre;
                    Obj.apellido        = item.apellido;
                    Obj.telefono        = item.telefono;
                    Obj.ci              = item.ci;
                    Obj.fechaNacimiento = item.fechaNacimiento;
                    Obj.direccion       = item.direccion;
                    Obj.sexo            = item.sexo;
                    Obj.estado          = item.estado;


                    return(Obj);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #3
0
        public EPaciente mostraDatos(int id)
        {
            try
            {
                using (dbodontogramaEntity cn = new dbodontogramaEntity())
                {
                    paciente item = new paciente();
                    item = cn.paciente.Find(id);
                    EPaciente Obj = new EPaciente();
                    Obj.pacienteID      = item.pacienteID;
                    Obj.nombre          = item.nombre;
                    Obj.apellido        = item.apellido;
                    Obj.telefono        = item.telefono;
                    Obj.ci              = item.ci;
                    Obj.fechaNacimiento = item.fechaNacimiento;
                    Obj.direccion       = item.direccion;
                    Obj.sexo            = item.sexo;
                    Obj.estado          = item.estado;


                    return(Obj);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #4
0
 public void registrarPaciente(EPaciente ModelPaciente)
 {
     if (validarProducto(ModelPaciente))
     {
         _dpaciente.insertar(ModelPaciente);
     }
 }
예제 #5
0
        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["pacienteID"].Value);
                    EPaciente Obj = new EPaciente();
                    Obj.pacienteID = Convert.ToInt32(Codigo);
                    Rpta           = Convert.ToString(NPacientes.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.LimpiarPRegistro();
                    this.txtId.Text        = Convert.ToString(this.dataListado.CurrentRow.Cells["pacienteID"].Value);
                    this.txtNombre.Text    = Convert.ToString(this.dataListado.CurrentRow.Cells["nombre"].Value);
                    this.txtApellido.Text  = Convert.ToString(this.dataListado.CurrentRow.Cells["apellido"].Value);
                    this.txtTelefono.Text  = Convert.ToString(this.dataListado.CurrentRow.Cells["telefono"].Value);
                    this.txtCI.Text        = Convert.ToString(this.dataListado.CurrentRow.Cells["ci"].Value);
                    this.txtFecha.Text     = Convert.ToString(this.dataListado.CurrentRow.Cells["fechaNacimiento"].Value);
                    this.txtDireccion.Text = Convert.ToString(this.dataListado.CurrentRow.Cells["direccion"].Value);
                    this.sexo = Convert.ToString(this.dataListado.CurrentRow.Cells["sexo"].Value);

                    if (this.sexo == "Masculino")
                    {
                        this.txtM.Checked = true;
                    }
                    else
                    {
                        this.txtF.Checked = true;
                    }

                    this.OcultarPRegistro(false, false);
                    this.lbModificar.Visible = true;
                    this.lbAgregar.Visible   = false;
                }
            }
        }
예제 #6
0
 public int Insertar(EPaciente paciente)
 {
     _contexto.AddToTB_PACIENTE(new TB_PACIENTE
     {
         nombres           = paciente.Nombres,
         ApellidoPat       = paciente.ApellidoPat,
         ApellidoMat       = paciente.ApellidoMat,
         Direccion         = paciente.Direccion,
         FechaNacimiento   = paciente.FechaNacimiento,
         Celular           = paciente.Telefono,
         TelefonoDomicilio = paciente.TelefonoCasa
     });
     _contexto.SaveChanges();
     return(paciente.CodigoPaciente);
 }
예제 #7
0
        public static long save(EPaciente Paciente)
        {
            try
            {
                CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity();
                List <paciente> pacientes       = new List <paciente>();
                paciente        Obj             = new paciente();

                pacientes = (from p in cn.paciente
                             where p.estado == 1
                             where p.nombre == Paciente.nombre && p.apellido == Paciente.apellido
                             select p).ToList();

                if (pacientes.Count > 0)
                {
                    throw new Exception("El Paciente Ya Existe");
                }

                Obj.nombre   = Paciente.nombre;
                Obj.apellido = Paciente.apellido;
                Obj.telefono = Paciente.telefono;
                if (Obj.nombre == string.Empty && Obj.apellido == string.Empty)
                {
                    throw new Exception("Ingrese Nombre y Apellido");
                }
                Obj.ci = Paciente.ci;
                Obj.fechaNacimiento = Paciente.fechaNacimiento;
                Obj.direccion       = Paciente.direccion;
                Obj.sexo            = Paciente.sexo;
                Obj.estado          = 1;
                cn.paciente.Add(Obj);
                int result = cn.SaveChanges();
                if (result > 0)
                {
                    return(Obj.pacienteID);
                }
                else
                {
                    throw new Exception("Error Al guardar El Registro");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #8
0
        public static long update(EPaciente Paciente)
        {
            try
            {
                CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity();
                List <paciente> pacientes       = new List <paciente>();
                paciente        Obj             = new paciente();

                pacientes = (from p in cn.paciente
                             where p.estado == 1
                             where p.nombre == Paciente.nombre && p.apellido == Paciente.apellido
                             select p).ToList();

                if (pacientes.Count > 1)
                {
                    throw new Exception("El Paciente Ya Existe");
                }

                Obj = (from p in cn.paciente
                       where p.pacienteID == Paciente.pacienteID
                       select p).First();

                Obj.nombre          = Paciente.nombre;
                Obj.apellido        = Paciente.apellido;
                Obj.telefono        = Paciente.telefono;
                Obj.ci              = Paciente.ci;
                Obj.fechaNacimiento = Paciente.fechaNacimiento;
                Obj.direccion       = Paciente.direccion;
                Obj.sexo            = Paciente.sexo;
                Obj.estado          = 1;
                int result = cn.SaveChanges();
                if (result > 0)
                {
                    return(Obj.pacienteID);
                }
                else
                {
                    throw new Exception("No hubo Ningun Cambio al Editar");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #9
0
        public static List <EPaciente> mostrar(string nombre, string apellido, int pag)
        {
            try
            {
                List <EPaciente> Pacientes = new List <EPaciente>();
                List <paciente>  pacientes = new List <paciente>();

                using (dbodontogramaEntity cn = new dbodontogramaEntity())
                {
                    pacientes = (from p in cn.paciente
                                 where p.estado == 1
                                 where p.nombre.Contains(nombre)
                                 where p.apellido.Contains(apellido)
                                 orderby p.pacienteID descending
                                 select p).ToList();

                    pag = pag * 10;
                    var tabla = pacientes.Skip(pag).Take(10);
                    if (pacientes.Count < pag)
                    {
                        tabla = pacientes.Skip(pag).Take(10);
                    }

                    foreach (var item in tabla)
                    {
                        EPaciente Obj = new EPaciente();
                        Obj.pacienteID      = item.pacienteID;
                        Obj.nombre          = item.nombre;
                        Obj.apellido        = item.apellido;
                        Obj.telefono        = item.telefono;
                        Obj.ci              = item.ci;
                        Obj.fechaNacimiento = item.fechaNacimiento;
                        Obj.direccion       = item.direccion;
                        Obj.sexo            = item.sexo;
                        Obj.estado          = item.estado;
                        Pacientes.Add(Obj);
                    }
                    return(Pacientes);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #10
0
 public void insertar(EPaciente EntidadPaciente)
 {
     try
     {
         con.ConnectionString = Conexion.cn;
         con.Open();
         MySqlCommand cmd = con.CreateCommand();
         cmd.CommandText = "INSERT INTO paciente (id,nombre,apellido) value (@param1,@param2,@param3)";
         cmd.Parameters.AddWithValue("@param1", EntidadPaciente.id);
         cmd.Parameters.AddWithValue("@param2", EntidadPaciente.nombre);
         cmd.Parameters.AddWithValue("@param3", EntidadPaciente.apellido);
         cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
 }
예제 #11
0
 public string Modificar(EPaciente obj)
 {
     try
     {
         SqlConnection con    = db.ConectaDb();
         string        update = string.Format("update Paciente set nombre='{0}',apellido='{1}',telefono='{2}',sexo='{3}',edad={4},padecimiento='{5}',codigocita={6} where dni='{7}',", obj.Nombre, obj.Apellido, obj.Telefono, obj.Sexo, obj.Edad, obj.Padecimiento, obj.CodigoCita.Codigo, obj.DNI);
         SqlCommand    cmd    = new SqlCommand(update, con);
         cmd.ExecuteNonQuery();
         return("Modifico");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
     finally
     {
         db.DesconectaDb();
     }
 }
예제 #12
0
 public string Insertar(EPaciente obj)
 {
     try
     {
         SqlConnection con    = db.ConectaDb();
         string        insert = string.Format("Insert into Paciente(nombre,apellido,dni,telefono,sexo,edad,padecimiento,codigocita) values('{0}','{1}','{2}','{3}','{4}',{5},'{6}',{7})", obj.Nombre, obj.Apellido, obj.DNI, obj.Telefono, obj.Sexo, obj.Edad, obj.Padecimiento, obj.CodigoCita.Codigo);
         SqlCommand    cmd    = new SqlCommand(insert, con);
         cmd.ExecuteNonQuery();
         return("Inserto");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
     finally
     {
         db.DesconectaDb();
     }
 }
예제 #13
0
        private bool validarProducto(EPaciente ModelPaciente)
        {
            stringBuilder.Clear();

            if ((ModelPaciente.id) < 0)
            {
                stringBuilder.Append("El campo ID es obligatorio");
            }
            if (string.IsNullOrEmpty(ModelPaciente.nombre))
            {
                stringBuilder.Append(Environment.NewLine + "El campo Nombre es obligatorio");
            }
            if (string.IsNullOrEmpty(ModelPaciente.apellido))
            {
                stringBuilder.Append(Environment.NewLine + "El campo Apellido es obligatorio");
            }

            //if (producto.Precio <= 0) stringBuilder.Append(Environment.NewLine + "El campo Precio es obligatorio");

            return(stringBuilder.Length == 0);
        }
예제 #14
0
        public string ModificarPacientedatos(string nombre, string apellido, string dni, string telefono, string sexo, int edad, string padecimiento, int codigocita)
        {
            ECitaMedica cita = new ECitaMedica()
            {
                Codigo = codigocita
            };

            EPaciente paciente = new EPaciente()
            {
                Nombre       = nombre,
                Apellido     = apellido,
                DNI          = dni,
                Telefono     = telefono,
                Sexo         = sexo,
                Edad         = edad,
                Padecimiento = padecimiento,
                CodigoCita   = cita
            };

            return(Pacientedatos.Modificar(paciente));
        }
예제 #15
0
        //expresiones Landan y Delegados
        //user Control
        public static string delete(EPaciente Paciente)
        {
            string rpta = "";

            try
            {
                CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity();
                paciente Obj = new paciente();
                //Obj = (from p in cn.paciente
                //       where p.id == Paciente.id
                //       select p).First();
                Obj        = cn.paciente.Find(Paciente.pacienteID);
                rpta       = Obj.estado == 1 ? "OK" : "No se Puede Eliminar el Registro";
                Obj.estado = 0;
                cn.SaveChanges();
            }
            catch (Exception ex)
            {
                rpta = (ex.Message);
            }
            return(rpta);
        }
예제 #16
0
        public static List <EPaciente> mostrarTodo()
        {
            try
            {
                List <EPaciente> Pacientes = new List <EPaciente>();
                List <paciente>  pacientes = new List <paciente>();

                using (dbodontogramaEntity cn = new dbodontogramaEntity())
                {
                    pacientes = (from p in cn.paciente
                                 where p.estado == 1
                                 select p).ToList();



                    foreach (var item in pacientes)
                    {
                        EPaciente Obj = new EPaciente();
                        Obj.pacienteID      = item.pacienteID;
                        Obj.nombre          = item.nombre;
                        Obj.apellido        = item.apellido;
                        Obj.telefono        = item.telefono;
                        Obj.ci              = item.ci;
                        Obj.fechaNacimiento = item.fechaNacimiento;
                        Obj.direccion       = item.direccion;
                        Obj.sexo            = item.sexo;
                        Obj.estado          = item.estado;
                        Pacientes.Add(Obj);
                    }
                    return(Pacientes);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #17
0
 public List <EPaciente> ListarTodo() //CORREGIR AS PAS
 {
     try
     {
         List <EPaciente> Lsdatos  = new List <EPaciente>();
         EPaciente        objDatos = null;
         //DateTime d;
         SqlConnection con    = db.ConectaDb();
         SqlCommand    cmd    = new SqlCommand("select pa.nombre,pa.apellido,pa.dni,pa.telefono,pa.sexo,pa.edad,pa.padecimiento,cit.codigocita as CitaMedica,cit.codcita from CitaMedica as cit, Paciente as pa where cit.=pa.CodigoCita", con);
         SqlDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             objDatos        = new EPaciente();
             objDatos.Nombre = (string)reader["nombre"];
             //d = (DateTime)reader["fecha"];
             //objDatos.Fecha = d.ToShortDateString();
             objDatos.Apellido     = (string)reader["apellido"];
             objDatos.DNI          = (string)reader["dni"];
             objDatos.Telefono     = (string)reader["telefono"];
             objDatos.Sexo         = (string)reader["sexo"];
             objDatos.Edad         = (int)reader["edad"];
             objDatos.Padecimiento = (string)reader["padecimiento"];
             objDatos.CodigoCita   = (ECitaMedica)reader["codigocita"];
             Lsdatos.Add(objDatos);
         }
         reader.Close();
         return(Lsdatos);
     }
     catch (Exception e)
     {
         return(null);
     }
     finally
     {
         db.DesconectaDb();
     }
 }
예제 #18
0
        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);
            }
        }
예제 #19
0
        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);
            }
        }