コード例 #1
0
        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 oSeccion, a);

                        oSeccion[a - 1]                    = new SeccionEN();
                        oSeccion[a - 1].idSeccion          = Convert.ToInt32(Fila.Cells["idSeccion"].Value);
                        oSeccion[a - 1].Nombre             = Fila.Cells["Nombre"].Value.ToString();
                        oSeccion[a - 1].Descripcion        = Fila.Cells["Descripcion"].Value.ToString();
                        oSeccion[a - 1].Codigo             = Fila.Cells["Codigo"].Value.ToString();
                        oSeccion[a - 1].CodigoDeAlmacenaje = Fila.Cells["CodigoDeAlmacenaje"].Value.ToString();
                    }
                }

                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
コード例 #2
0
        private string InformacionDelRegistro(SeccionEN oRegistroEN)
        {
            string Cadena = @"idSeccion: {0}, Codigo: {7}, Nombre: {1}, Descripcion: {2}, idUsuarioDeCreacion: {3}, FechaDeCreacion: {4}, idUsuarioModificacion: {5}, FechaDeModificacion: {6}";

            Cadena = string.Format(Cadena, oRegistroEN.idSeccion, oRegistroEN.Nombre, oRegistroEN.Descripcion, oRegistroEN.idUsuarioDeCreacion, oRegistroEN.FechaDeCreacion, oRegistroEN.idUsuarioModificacion, oRegistroEN.FechaDeModificacion, oRegistroEN.Codigo);
            Cadena = Cadena.Replace(",", Environment.NewLine);
            return(Cadena);
        }
コード例 #3
0
        public bool Eliminar(SeccionEN 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 Seccion Where idSeccion = @idSeccion;";
                Comando.CommandText = Consultas;

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

                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;
            }
        }
コード例 #4
0
 public bool ListadoPorIdLocacion(SeccionEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oSeccionAD.ListadoPorIdLocacion(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oSeccionAD.Error;
         return(false);
     }
 }
コード例 #5
0
 public bool ValidarSiElRegistroEstaVinculadoParaActualizacion(SeccionEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oSeccionAD.ValidarSiElRegistroEstaVinculadoParaActualizacion(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oSeccionAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
コード例 #6
0
 public bool VerificarSiLaEntidadEstaAsociadaAProducto(SeccionEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oSeccionAD.VerificarSiLaEntidadEstaAsociadaAProducto(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oSeccionAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
コード例 #7
0
 public bool ValidarCodigo(SeccionEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oSeccionAD.ValidarCodigo(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oSeccionAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
コード例 #8
0
 public bool Agregar(SeccionEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oSeccionAD.Agregar(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oSeccionAD.Error;
         return(false);
     }
 }
コード例 #9
0
        public bool Listado(SeccionEN 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 
                s.idSeccion, s.idLocacion, b.idBodega, a.idAlmacen, 
                concat(a.Codigo,'-',b.Codigo,'-',l.Codigo,'-',s.Codigo) as 'CodigoDeAlmacenaje',
                s.Codigo, s.Nombre, s.Descripcion
                from seccion as s
                inner join locacion as l on l.idLocacion = s.idLocacion
                inner join bodega as b on b.idBodega = l.idBodega 
                inner join almacen as a on a.idAlmacen = b.idAlmacen
                Where s.idSeccion > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy);
                Comando.CommandText = 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;
            }
        }
コード例 #10
0
        public bool ListadoDeContenedoresPorSeccion(SeccionEN 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 scc.idSeccionContenedor, scc.idContenedor,
                cr.Codigo, cr.Nombre, cr.Descripcion
                from seccioncontenedor scc
                inner join seccion as sc on sc.idSeccion = scc.idSeccion
                inner join contenedor as cr on cr.idContenedor = scc.idContenedor
                where scc.idSeccion = {0} Order By cr.Codigo ", oRegistroEN.idSeccion);
                Comando.CommandText = 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;
            }
        }
コード例 #11
0
        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 oSeccion, a);

                            oSeccion[a - 1]                    = new SeccionEN();
                            oSeccion[a - 1].idSeccion          = Convert.ToInt32(Fila.Cells["idSeccion"].Value);
                            oSeccion[a - 1].Nombre             = Fila.Cells["Nombre"].Value.ToString();
                            oSeccion[a - 1].Descripcion        = Fila.Cells["Descripcion"].Value.ToString();
                            oSeccion[a - 1].Codigo             = Fila.Cells["Codigo"].Value.ToString();
                            oSeccion[a - 1].CodigoDeAlmacenaje = Fila.Cells["CodigoDeAlmacenaje"].Value.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Seleccionar registros", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally {
                AgregarRegistrosAlDTUsuario();
                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
コード例 #12
0
        public bool ListadoParaReportes(SeccionEN 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 idSeccion, s.Codigo,s.Nombre, Descripcion, s.idUsuarioDeCreacion, 
                s.FechaDeCreacion, s.idUsuarioModificacion, s.FechaDeModificacion 
                from Seccion as s
                inner join usuario as u on u.idUsuario = s.idUsuarioDeCreacion
                left join usuario as u1 on u1.idUsuario = s.idUsuarioModificacion
                where idSeccion > 0  {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy);
                Comando.CommandText = 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;
            }
        }
コード例 #13
0
        public bool ListadoParaCombos(SeccionEN 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 idSeccion, s.Nombre, concat(s.Codigo, '-', s.Nombre) as 'Seccion'
                from Seccion as s                
                where s.idSeccion > 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;
            }
        }
コード例 #14
0
        public bool ListadoPorIdLocacion(SeccionEN 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  idSeccion, idLocacion, Codigo, Nombre, Descripcion
                from seccion
                where idLocacion = {0} {1} ", oRegistroEN.oLocacionEN.idLocacion, oRegistroEN.OrderBy);
                Comando.CommandText = 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;
            }
        }
コード例 #15
0
        private void LLenarComboSeccion()
        {
            try
            {
                SeccionEN oRegistroEN = new SeccionEN();

                if (cmbLocacion.SelectedIndex > -1)
                {
                    oRegistroEN.Where = string.Format(" and s.idLocacion = {0} ", cmbLocacion.SelectedValue);
                }
                else
                {
                    oRegistroEN.Where = "";
                }

                oRegistroEN.OrderBy = " Order by s.Nombre asc ";

                SeccionLN oRegistroLN = new SeccionLN();

                if (oRegistroLN.ListadoParaCombos(oRegistroEN, Program.oDatosDeConexion))
                {
                    cmbSeccion.DataSource    = oRegistroLN.TraerDatos();
                    cmbSeccion.DisplayMember = "Seccion";
                    cmbSeccion.ValueMember   = "idSeccion";
                    cmbSeccion.DropDownWidth = 268;

                    if (oRegistroLN.TraerDatos().Rows.Count == 1)
                    {
                        cmbSeccion.SelectedIndex = 0;
                    }
                    else
                    {
                        cmbSeccion.SelectedIndex = -1;
                    }
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Informacion de la sección", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #16
0
        public bool Eliminar(SeccionEN oREgistroEN, DatosDeConexionEN oDatos)
        {
            if (string.IsNullOrEmpty(oREgistroEN.idSeccion.ToString()) || oREgistroEN.idSeccion == 0)
            {
                this.Error = @"Se debe de seleccionar un elemento de la lista";
                return(false);
            }

            if (oSeccionAD.Eliminar(oREgistroEN, oDatos))
            {
                Error = string.Empty;
                return(true);
            }
            else
            {
                Error = oSeccionAD.Error;
                return(false);
            }
        }
コード例 #17
0
        private TransaccionesEN InformacionDelaTransaccion(SeccionEN oSeccion, String TipoDeOperacion, String Descripcion, String Estado)
        {
            TransaccionesEN oRegistroEN = new TransaccionesEN();

            oRegistroEN.idregistro      = oSeccion.idSeccion;
            oRegistroEN.Modelo          = "General";
            oRegistroEN.Modulo          = "SeccionAD";
            oRegistroEN.Tabla           = "Seccion";
            oRegistroEN.tipodeoperacion = TipoDeOperacion;
            oRegistroEN.Estado          = Estado;
            oRegistroEN.ip                    = oSeccion.oLoginEN.NumeroIP;
            oRegistroEN.idusuario             = oSeccion.oLoginEN.idUsuario;
            oRegistroEN.idusuarioaprueba      = oSeccion.oLoginEN.idUsuario;
            oRegistroEN.descripciondelusuario = DescripcionDeOperacion;
            oRegistroEN.descripcioninterna    = Descripcion;
            oRegistroEN.NombreDelEquipo       = oSeccion.oLoginEN.NombreDelComputador;

            return(oRegistroEN);
        }
コード例 #18
0
        private void LLenarListado()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                SeccionEN oRegistrosEN = new SeccionEN();
                SeccionLN oRegistrosLN = new SeccionLN();

                oRegistrosEN.Where = WhereDinamico();

                if (oRegistrosLN.Listado(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;
            }
        }
コード例 #19
0
        public bool Agregar(SeccionEN 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 seccion
                (idLocacion, Codigo, Nombre, Descripcion, idUsuarioDeCreacion, 
                FechaDeCreacion, idUsuarioModificacion, FechaDeModificacion)
                values
                (@idLocacion, @Codigo, @Nombre, @Descripcion, @idUsuarioDeCreacion, 
                current_timestamp(), @idUsuarioModificacion, current_timestamp());

                Select last_insert_id() as 'ID';
                                ";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idLocacion", MySqlDbType.Int32)).Value = oRegistroEN.oLocacionEN.idLocacion;
                Comando.Parameters.Add(new MySqlParameter("@Codigo", MySqlDbType.VarChar, oRegistroEN.Codigo.Length)).Value           = oRegistroEN.Codigo.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Length)).Value           = oRegistroEN.Nombre.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Descripcion", MySqlDbType.VarChar, oRegistroEN.Descripcion.Length)).Value = oRegistroEN.Descripcion.Trim();
                Comando.Parameters.Add(new MySqlParameter("@idUsuarioDeCreacion", MySqlDbType.Int32)).Value   = oRegistroEN.oLoginEN.idUsuario;
                Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario;

                Adaptador = new MySqlDataAdapter();
                Adaptador.SelectCommand = Comando;
                DT = new DataTable();
                Adaptador.Fill(DT);

                oRegistroEN.idSeccion = 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;
            }
        }
コード例 #20
0
        public bool ValidarCodigo(SeccionEN 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 idSeccion from Seccion where idLocacion= @idLocacion and upper( trim(Codigo) ) = upper(trim(@Codigo))) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@Codigo", MySqlDbType.VarChar, oRegistroEN.Codigo.Trim().Length)).Value = oRegistroEN.Codigo;
                    Comando.Parameters.Add(new MySqlParameter("@idLocacion", MySqlDbType.Int32)).Value = oRegistroEN.oLocacionEN.idLocacion;

                    break;

                case "ACTUALIZAR":

                    Consultas = @"SELECT CASE WHEN EXISTS(Select idSeccion from Seccion where idLocacion = @idLocacion and upper( trim(Codigo) ) = upper(trim(@Codigo)) and idSeccion <> @idSeccion) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@Codigo", MySqlDbType.VarChar, oRegistroEN.Codigo.Trim().Length)).Value = oRegistroEN.Codigo;
                    Comando.Parameters.Add(new MySqlParameter("@idSeccion", MySqlDbType.Int32)).Value  = oRegistroEN.idSeccion;
                    Comando.Parameters.Add(new MySqlParameter("@idLocacion", MySqlDbType.Int32)).Value = oRegistroEN.oLocacionEN.idLocacion;

                    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 Código 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;
            }
        }
コード例 #21
0
        public bool VerificarSiLaEntidadEstaAsociadaAProducto(SeccionEN 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;
                Comando.CommandText = string.Format(@"Select case when exists(
                Select idProducto from producto as p
                where p.TablaDeReferenciaDeAlmacenaje = 'Seccion' and p.idAlmacenEntidad = {0}) then 1 else 0 end as 'ID'", oRegistroEN.idSeccion);

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

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

                if (Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()) == 0)
                {
                    return(false);
                }
                else
                {
                    this.Error             = string.Format("La Operacion: '{1}', {0} no se puede completar por que el registro: {0} '{2}', ya tiene asociado un producto", Environment.NewLine, TipoDeOperacion, InformacionDelRegistro(oRegistroEN));
                    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;
            }
        }
コード例 #22
0
        public bool ValidarSiElRegistroEstaVinculadoParaActualizacion(SeccionEN 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 = "idSeccion";
                Comando.Parameters.Add(new MySqlParameter("@ValorCampoABuscar", MySqlDbType.Int32)).Value    = oRegistroEN.idSeccion;
                Comando.Parameters.Add(new MySqlParameter("@ExcluirTabla_", MySqlDbType.VarChar, 200)).Value = "'Seccion','Contenedor'";

                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;
            }
        }
コード例 #23
0
        public bool Actualizar(SeccionEN 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 = @"update seccion set
                idLocacion = @idLocacion, Codigo = @Codigo, Nombre = @Nombre, Descripcion = @Descripcion,  
                idUsuarioModificacion = @idUsuarioModificacion, FechaDeModificacion = current_timestamp()
                Where idSeccion = @idSeccion;";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idSeccion", MySqlDbType.Int32)).Value  = oRegistroEN.idSeccion;
                Comando.Parameters.Add(new MySqlParameter("@idLocacion", MySqlDbType.Int32)).Value = oRegistroEN.oLocacionEN.idLocacion;
                Comando.Parameters.Add(new MySqlParameter("@Codigo", MySqlDbType.VarChar, oRegistroEN.Codigo.Trim().Length)).Value           = oRegistroEN.Codigo.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value           = oRegistroEN.Nombre.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Descripcion", MySqlDbType.VarChar, oRegistroEN.Descripcion.Trim().Length)).Value = oRegistroEN.Descripcion.Trim();
                Comando.Parameters.Add(new MySqlParameter("@idUsuarioModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario;

                Comando.ExecuteNonQuery();

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

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar 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 actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar 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;
            }
        }