示例#1
0
        private void LLenarCampoDeBaseDeDatosSegunLaboratorios()
        {
            try
            {
                ProveedorLaboratorioEN oRegistroEN = new ProveedorLaboratorioEN();
                ProveedorLaboratorioLN oRegistroLN = new ProveedorLaboratorioLN();

                oRegistroEN.oLaboratorioEN.idLaboratorio = ValorLlavePrimariaEntidad;

                if (oRegistroLN.ListadoPorID_LabortoriosInformacion(oRegistroEN, Program.oDatosDeConexion))
                {
                    if (oRegistroLN.TraerDatos().Rows.Count > 0)
                    {
                        foreach (DataRow Fila in oRegistroLN.TraerDatos().Rows)
                        {
                            lbListaDeProveedores.Items.Add(Fila["Proveedor"].ToString());
                        }
                    }
                    else
                    {
                        cmbProveedor.SelectedIndex = -1;
                    }
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Informacion del proveedor asociado al Laboratorio", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void LLenarCampoDeBaseDeDatosSegundLaboratorio()
        {
            try
            {
                ProveedorLaboratorioEN oRegistroEN = new ProveedorLaboratorioEN();
                ProveedorLaboratorioLN oRegistroLN = new ProveedorLaboratorioLN();

                oRegistroEN.oLaboratorioEN.idLaboratorio = ValorLlavePrimariaEntidad;

                if (oRegistroLN.ListadoPorIdentificadorDelLaboratorio(oRegistroEN, Program.oDatosDeConexion))
                {
                    if (oRegistroLN.TraerDatos().Rows.Count > 0)
                    {
                        cmbProveedor.SelectedValue     = oRegistroEN.oProveedorEN.idProveedor;
                        txtIdProveedorLaboratorio.Text = oRegistroEN.idProveedorLaboratorio.ToString();
                    }
                    else
                    {
                        cmbProveedor.SelectedIndex = -1;
                    }
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Informacion del proveedor asociado al Laboratorio", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#3
0
        private void EliminarRegistroDelaVinculacion()
        {
            try
            {
                ProveedorLaboratorioEN oRegistroEN = new ProveedorLaboratorioEN();
                ProveedorLaboratorioLN oRegistroLN = new ProveedorLaboratorioLN();

                oRegistroEN.oLaboratorioEN           = InformacionDelRegistro();
                oRegistroEN.idProveedorLaboratorio   = Convert.ToInt32(txtIdProveedorLaboratorio.Text);
                oRegistroEN.oProveedorEN.idProveedor = Convert.ToInt32(cmbProveedor.SelectedValue);
                oRegistroEN.oProveedorEN.Nombre      = cmbProveedor.Text.Trim();
                oRegistroEN.oLoginEN                = Program.oLoginEN;
                oRegistroEN.IdUsuarioDeCreacion     = Program.oLoginEN.idUsuario;
                oRegistroEN.IdUsuarioDeModificacion = Program.oLoginEN.idUsuario;
                oRegistroEN.FechaDeCreacion         = System.DateTime.Now;
                oRegistroEN.FechaDeModificacion     = System.DateTime.Now;

                if (oRegistroLN.Eliminar(oRegistroEN, Program.oDatosDeConexion) == false)
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Información del Proveedor", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void tsbSeleccionarTodos_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                tsbSeleccionarTodos.Checked = !tsbMarcarTodos.Checked;

                if (tsbSeleccionarTodos.Checked == true)
                {
                    tsbSeleccionarTodos.Image = Properties.Resources.unchecked16x16;
                }
                else
                {
                    tsbSeleccionarTodos.Image = Properties.Resources.checked16x16;
                }

                int a = 0;
                this.Cursor = Cursors.WaitCursor;

                if (dgvLista.Rows.Count > 0)
                {
                    foreach (DataGridViewRow Fila in dgvLista.Rows)
                    {
                        if (Convert.ToBoolean(Fila.Cells["Seleccionar"].Value) == true)
                        {
                            a++;
                            Array.Resize(ref oProveedorLaboratorioEN, a);
                            ProveedorLaboratorioEN oRegistroEN = new ProveedorLaboratorioEN();

                            oRegistroEN.idProveedorLaboratorio = Convert.ToInt32(Fila.Cells["idProveedorLaboratorio"].Value.ToString());
                            oRegistroEN.TablaDeReferencia      = Fila.Cells["TablaDeReferencia"].Value.ToString().Trim();

                            switch (oRegistroEN.TablaDeReferencia)
                            {
                            case "ProveedorLaboratorio":
                                oRegistroEN.ProveedorLaboratorio = Fila.Cells["Laboratorio"].Value.ToString();
                                break;

                            default:
                                oRegistroEN.ProveedorLaboratorio = Fila.Cells["ProveedorLaboratorio"].Value.ToString();
                                break;
                            }

                            oProveedorLaboratorioEN[a - 1] = oRegistroEN;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Seleccionar registros", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally {
                //AgregarRegistrosAlDTUsuario();
                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
示例#5
0
        private string InformacionDelRegistro(ProveedorLaboratorioEN oRegistroEN)
        {
            string Cadena = @"idProveedorLaboratorio: {0}, idProveedor: {1}, idLaboratorio: {2}, idUsuarioDeCreacion: {3}, FechaDeCreacion: {4}, idUsuarioModificacion: {5}, FechaDeModificacion: {6}";

            Cadena = string.Format(Cadena, oRegistroEN.idProveedorLaboratorio, oRegistroEN.oProveedorEN.idProveedor, oRegistroEN.oLaboratorioEN.idLaboratorio, oRegistroEN.IdUsuarioDeCreacion, oRegistroEN.FechaDeCreacion, oRegistroEN.IdUsuarioDeModificacion, oRegistroEN.FechaDeModificacion);
            Cadena = Cadena.Replace(",", Environment.NewLine);
            return(Cadena);
        }
示例#6
0
        public bool ListadoPorIdentificadorDelProveedor(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas = string.Format(@"Select pc.idProveedorLaboratorio, pc.idLaboratorio, Codigo, c.Nombre, c.NoRUC,Direccion, Telefono, Movil,
                Observaciones, Correo, SitioWeb, FechaDeCumpleanos, Messenger, Skype, 
                Twitter, Facebook, c.Estado
                from ProveedorLaboratorio pc 
                inner join Laboratorio as c on c.idLaboratorio = pc.idLaboratorio
                inner join usuario as u on u.idUsuario = c.idUsuarioDeCreacion
                left join usuario as c1 on c1.idUsuario = c.idUsuarioModificacion
                where pc.idProveedor = {0} ", oRegistroEN.oProveedorEN.idProveedor);

                //System.Diagnostics.Debug.Print(string.Format("Consulta: {0} {1} {0}", Environment.NewLine,Consultas));
                Comando.CommandText = Consultas;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                if (DT.Rows.Count > 0)
                {
                    oRegistroEN.idProveedorLaboratorio   = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString());
                    oRegistroEN.oProveedorEN.idProveedor = Convert.ToInt32(DT.Rows[0].ItemArray[1].ToString());
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn       = null;
                Comando   = null;
                Adaptador = null;
            }
        }
示例#7
0
        public bool Eliminar(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas           = @"Delete from ProveedorLaboratorio Where idProveedorLaboratorio = @idProveedorLaboratorio;";
                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idProveedorLaboratorio", MySqlDbType.Int32)).Value = oRegistroEN.idProveedorLaboratorio;

                Comando.ExecuteNonQuery();

                DescripcionDeOperacion = string.Format("El registro fue Eliminado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Eliminar", "Elminar Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al eliminar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Eliminar", "Eliminar Registro", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
示例#8
0
        public bool ListadoPorID_LabortoriosInformacion(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas           = string.Format(@"Select pc.idProveedorLaboratorio, pc.idProveedor, pc.idLaboratorio, concat(p.Codigo, ' - ', p.Nombre) as 'Proveedor'                  
                from ProveedorLaboratorio as pc              
                inner join proveedor as p on p.idProveedor = pc.idProveedor
                Where pc.idLaboratorio = {0} ", oRegistroEN.oLaboratorioEN.idLaboratorio);
                Comando.CommandText = Consultas;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                if (DT.Rows.Count > 0)
                {
                    oRegistroEN.idProveedorLaboratorio   = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString());
                    oRegistroEN.oProveedorEN.idProveedor = Convert.ToInt32(DT.Rows[0].ItemArray[1].ToString());
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn       = null;
                Comando   = null;
                Adaptador = null;
            }
        }
示例#9
0
 public bool ListadoPorID_LabortoriosInformacion(ProveedorLaboratorioEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oProveedorLaboratorioAD.ListadoPorID_LabortoriosInformacion(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oProveedorLaboratorioAD.Error;
         return(false);
     }
 }
示例#10
0
 public bool ValidarSiElRegistroEstaVinculado(ProveedorLaboratorioEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oProveedorLaboratorioAD.ValidarSiElRegistroEstaVinculado(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oProveedorLaboratorioAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
示例#11
0
 public bool ListadoDeProveedoresLaboratorio(ProveedorLaboratorioEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oProveedorLaboratorioAD.ListadoDeProveedoresLaboratorio(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oProveedorLaboratorioAD.Error;
         return(false);
     }
 }
示例#12
0
        public bool ListadoParaCombos(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas           = string.Format(@"Select pc.idProveedorLaboratorio, pc.idProveedor, pc.idLaboratorio,
                pc.idUsuarioDeCreacion, pc.FechaDeCreacion, u.Nombre as 'UsuarioDeCreacion',
                pc.idUsuarioModificacion, pc.FechaDeModificacion, u1.Nombre as 'UsuarioDeModificacion'
                from ProveedorLaboratorio as pc 
                inner join usuario as u on u.idUsuario = pc.idUsuarioDeCreacion
                left join usuario as u1 on u1.idUsuario = pc.idUsuarioModificacion
                Where pc.idProveedorLaboratorio > 0 {0} {1} ; ", oRegistroEN.Where, oRegistroEN.OrderBy);
                Comando.CommandText = Consultas;

                System.Diagnostics.Debug.Print("Consultas de Tipo de transaccion: " + Consultas);

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn       = null;
                Comando   = null;
                Adaptador = null;
            }
        }
        private void LLenarListado()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                ProveedorLaboratorioEN oRegistrosEN = new ProveedorLaboratorioEN();
                ProveedorLaboratorioLN oRegistrosLN = new ProveedorLaboratorioLN();

                oRegistrosEN.Where = WhereDinamico();

                if (oRegistrosLN.ListadoDeProveedoresLaboratorio(oRegistrosEN, Program.oDatosDeConexion))
                {
                    dgvLista.Columns.Clear();
                    System.Diagnostics.Debug.Print(oRegistrosLN.TraerDatos().Rows.Count.ToString());

                    if (ActivarFiltros == true)
                    {
                        dgvLista.DataSource = AgregarColumnaSeleccionar(oRegistrosLN.TraerDatos());
                    }
                    else
                    {
                        dgvLista.DataSource = oRegistrosLN.TraerDatos();
                    }

                    FormatearDGV();
                    this.dgvLista.ClearSelection();

                    tsbNoRegistros.Text = "No. Registros: " + oRegistrosLN.TotalRegistros().ToString();
                }
                else
                {
                    throw new ArgumentException(oRegistrosLN.Error);
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Llenar listado de registro en la lista", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
示例#14
0
        private TransaccionesEN InformacionDelaTransaccion(ProveedorLaboratorioEN oProveedorLaboratorio, String TipoDeOperacion, String Descripcion, String Estado)
        {
            TransaccionesEN oRegistroEN = new TransaccionesEN();

            oRegistroEN.idregistro      = oProveedorLaboratorio.idProveedorLaboratorio;
            oRegistroEN.Modelo          = "TransaccionAD";
            oRegistroEN.Modulo          = "Transacciones";
            oRegistroEN.Tabla           = "ProveedorLaboratorios";
            oRegistroEN.tipodeoperacion = TipoDeOperacion;
            oRegistroEN.Estado          = Estado;
            oRegistroEN.ip                    = oProveedorLaboratorio.oLoginEN.NumeroIP;
            oRegistroEN.idusuario             = oProveedorLaboratorio.oLoginEN.idUsuario;
            oRegistroEN.idusuarioaprueba      = oProveedorLaboratorio.oLoginEN.idUsuario;
            oRegistroEN.descripciondelusuario = DescripcionDeOperacion;
            oRegistroEN.descripcioninterna    = Descripcion;
            oRegistroEN.NombreDelEquipo       = oProveedorLaboratorio.oLoginEN.NombreDelComputador;

            return(oRegistroEN);
        }
示例#15
0
        public bool Eliminar(ProveedorLaboratorioEN oREgistroEN, DatosDeConexionEN oDatos)
        {
            if (string.IsNullOrEmpty(oREgistroEN.idProveedorLaboratorio.ToString()) || oREgistroEN.idProveedorLaboratorio == 0)
            {
                this.Error = @"Se debe de seleccionar un elemento de la lista";
                return(false);
            }

            if (oProveedorLaboratorioAD.Eliminar(oREgistroEN, oDatos))
            {
                Error = string.Empty;
                return(true);
            }
            else
            {
                Error = oProveedorLaboratorioAD.Error;
                return(false);
            }
        }
示例#16
0
        public bool ListadoDeProveedoresLaboratorio(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.StoredProcedure;
                Comando.CommandText = "ListadoDeProveedoresLaboratorio";
                Comando.Parameters.Add(new MySqlParameter("@SWhere", MySqlDbType.VarChar, oRegistroEN.Where.Length)).Value = oRegistroEN.Where;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn       = null;
                Comando   = null;
                Adaptador = null;
            }
        }
        private void dgvLista_DoubleClick(object sender, EventArgs e)
        {
            if (ActivarFiltros == true)
            {
                int a = 0;
                this.Cursor = Cursors.WaitCursor;

                dgvLista.CurrentRow.Cells["Seleccionar"].Value = true;

                foreach (DataGridViewRow Fila in dgvLista.Rows)
                {
                    if (Convert.ToBoolean(Fila.Cells["Seleccionar"].Value) == true)
                    {
                        a++;
                        Array.Resize(ref oProveedorLaboratorioEN, a);
                        ProveedorLaboratorioEN oRegistroEN = new ProveedorLaboratorioEN();

                        oRegistroEN.idProveedorLaboratorio = Convert.ToInt32(Fila.Cells["idProveedorLaboratorio"].Value.ToString());
                        oRegistroEN.TablaDeReferencia      = Fila.Cells["TablaDeReferencia"].Value.ToString().Trim();

                        switch (oRegistroEN.TablaDeReferencia)
                        {
                        case "ProveedorLaboratorio":
                            oRegistroEN.ProveedorLaboratorio = Fila.Cells["Laboratorio"].Value.ToString();
                            break;

                        default:
                            oRegistroEN.ProveedorLaboratorio = Fila.Cells["ProveedorLaboratorio"].Value.ToString();
                            break;
                        }

                        oProveedorLaboratorioEN[a - 1] = oRegistroEN;
                    }
                }

                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
示例#18
0
        private void ActualizarVinculacionConElProveedor()
        {
            try
            {
                ProveedorLaboratorioEN oRegistroEN = new ProveedorLaboratorioEN();
                ProveedorLaboratorioLN oRegistroLN = new ProveedorLaboratorioLN();

                oRegistroEN.oLaboratorioEN           = InformacionDelRegistro();
                oRegistroEN.idProveedorLaboratorio   = Convert.ToInt32(txtIdProveedorLaboratorio.Text);
                oRegistroEN.oProveedorEN.idProveedor = Convert.ToInt32(cmbProveedor.SelectedValue);
                oRegistroEN.oProveedorEN.Nombre      = cmbProveedor.Text.Trim();
                oRegistroEN.oLoginEN                = Program.oLoginEN;
                oRegistroEN.IdUsuarioDeCreacion     = Program.oLoginEN.idUsuario;
                oRegistroEN.IdUsuarioDeModificacion = Program.oLoginEN.idUsuario;
                oRegistroEN.FechaDeCreacion         = System.DateTime.Now;
                oRegistroEN.FechaDeModificacion     = System.DateTime.Now;

                if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexion, "ACTUALIZAR"))
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show(oRegistroLN.Error, this.OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (oRegistroLN.Actualizar(oRegistroEN, Program.oDatosDeConexion))
                {
                    txtIdProveedorLaboratorio.Text = oRegistroEN.idProveedorLaboratorio.ToString();
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Información del Proveedor", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#19
0
        public bool ValidarRegistroDuplicado(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                switch (TipoDeOperacion.Trim().ToUpper())
                {
                case "AGREGAR":

                    Consultas = @"SELECT CASE WHEN EXISTS(Select idProveedorLaboratorio from ProveedorLaboratorio where idLaboratorio = @idLaboratorio and idProveedor = @idProveedor) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@idLaboratorio", MySqlDbType.Int32)).Value = oRegistroEN.oLaboratorioEN.idLaboratorio;
                    Comando.Parameters.Add(new MySqlParameter("@idProveedor", MySqlDbType.Int32)).Value   = oRegistroEN.oProveedorEN.idProveedor;

                    break;

                case "ACTUALIZAR":

                    Consultas = @"SELECT CASE WHEN EXISTS(Select idProveedorLaboratorio from ProveedorLaboratorio where idLaboratorio = @idLaboratorio and idProveedor = @idProveedor and idProveedorLaboratorio <> @idProveedorLaboratorio) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@idLaboratorio", MySqlDbType.Int32)).Value          = oRegistroEN.oLaboratorioEN.idLaboratorio;
                    Comando.Parameters.Add(new MySqlParameter("@idProveedor", MySqlDbType.Int32)).Value            = oRegistroEN.oProveedorEN.idProveedor;
                    Comando.Parameters.Add(new MySqlParameter("@idProveedorLaboratorio", MySqlDbType.Int32)).Value = oRegistroEN.idProveedorLaboratorio;

                    break;

                default:
                    throw new ArgumentException("La aperación solicitada no esta disponible");
                }

                Comando.CommandText = Consultas;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                if (Convert.ToInt32(DT.Rows[0]["RES"].ToString()) > 0)
                {
                    DescripcionDeOperacion = string.Format("Ya existe información del Registro dentro de nuestro sistema: {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));
                    this.Error             = DescripcionDeOperacion;
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "REGISTRO DUPLICADO DENTRO DE LA BASE DE DATOS", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
示例#20
0
        public bool ValidarSiElRegistroEstaVinculado(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.StoredProcedure;
                Comando.CommandText = "ValidarSiElRegistroEstaVinculado";

                Comando.Parameters.Add(new MySqlParameter("@CampoABuscar_", MySqlDbType.VarChar, 200)).Value = "idProveedorLaboratorio";
                Comando.Parameters.Add(new MySqlParameter("@ValorCampoABuscar", MySqlDbType.Int32)).Value    = oRegistroEN.idProveedorLaboratorio;
                Comando.Parameters.Add(new MySqlParameter("@ExcluirTabla_", MySqlDbType.VarChar, 200)).Value = string.Empty;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                if (DT.Rows[0].ItemArray[0].ToString().ToUpper() == "NINGUNA".ToUpper())
                {
                    return(false);
                }
                else
                {
                    this.Error             = String.Format("La Operación: '{1}', {0} no se puede completar por que el registro: {0} '{2}', {0} se encuentra asociado con: {0} {3}", Environment.NewLine, TipoDeOperacion, InformacionDelRegistro(oRegistroEN), oTransaccionesAD.ConvertirValorDeLaCadena(DT.Rows[0].ItemArray[0].ToString()));
                    DescripcionDeOperacion = this.Error;

                    //Agregamos la Transacción....
                    TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "CORRECTO");
                    oTransaccionesAD.Agregar(oTran, oDatos);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
示例#21
0
        public bool Agregar(ProveedorLaboratorioEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas = @"
                                
                insert into ProveedorLaboratorio
                (idProveedor, idLaboratorio, 
                idUsuarioDeCreacion, FechaDeCreacion, 
                idUsuarioModificacion, FechaDeModificacion)
                values
                (@idProveedor, @idLaboratorio, 
                @idUsuarioDeCreacion, current_timestamp(), 
                @idUsuarioModificacion, current_timestamp());

                Select last_insert_id() as 'ID';";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idProveedor", MySqlDbType.Int32)).Value           = oRegistroEN.oProveedorEN.idProveedor;
                Comando.Parameters.Add(new MySqlParameter("@idLaboratorio", MySqlDbType.Int32)).Value         = oRegistroEN.oLaboratorioEN.idLaboratorio;
                Comando.Parameters.Add(new MySqlParameter("@idUsuarioDeCreacion", MySqlDbType.Int32)).Value   = oRegistroEN.IdUsuarioDeCreacion;
                Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.IdUsuarioDeModificacion;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                oRegistroEN.idProveedorLaboratorio = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString());

                DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }