Exemple #1
0
        public ProductDetails(string clave)
        {
            InitializeComponent();
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            DataTable dt = new DataTable();

            connection.AbrirConexion();
            SqlDataAdapter da = connection.consultaMasDatos("select Id, Nombre from Categoria");

            da.Fill(dt);
            connection.CerrarConexion();
            cBoxCategoriaProd.DisplayMember = "Nombre";
            cBoxCategoriaProd.ValueMember   = "Id";
            cBoxCategoriaProd.DataSource    = dt;
            connection.AbrirConexion();
            SqlDataReader dataReader = connection.consulta("SELECT ClaveProducto AS Clave, ClaveFabricante AS Fabricante, Marca, Categoria.Nombre AS Categoria, Descripcion, Costo, Cantidad from Producto INNER JOIN Categoria ON Producto.IdCategoria = Categoria.Id WHERE ClaveProducto ='" + clave + "'");

            if (dataReader.Read())
            {
                tBoxClaveProducto.Text   = Convert.ToString(dataReader["Clave"]);
                tBoxClaveFabricante.Text = Convert.ToString(dataReader["Fabricante"]);
                tBoxMarca.Text           = Convert.ToString(dataReader["Marca"]);
                cBoxCategoriaProd.Text   = Convert.ToString(dataReader["Categoria"]);
                tBoxDescripcion.Text     = Convert.ToString(dataReader["Descripcion"]);
                tBoxCostoProducto.Text   = Convert.ToString(dataReader["Costo"]);
                tBoxCantidadProd.Text    = Convert.ToString(dataReader["Cantidad"]);
            }
            claveProducto = clave;
            connection.CerrarConexion();
        }
 private void btnAceptarCancelacionVenta_Click(object sender, System.EventArgs e)
 {
     if (txtMotivoDeCancelacion.Text == "")
     {
         MessageBox.Show("Es necesario agregar un motivo de cancelación", "¿Motivo?", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
     else
     {
         Connection connection = new Connection();
         connection.AbrirConexion();
         decimal id = UltimoIdIngresado();
         //-------------------------------------------------------------------
         //Buscar IdUsuario
         int idUsuario = Convert.ToInt32(connection.getIdUsuario("SELECT Id FROM Usuario WHERE NombreUsuario = '" + responsable + "'"));
         connection.CerrarConexion();
         //-------------------------------------------------------------------
         //Insertar datos en tabla cancelacion
         connection.AbrirConexion();
         string mifecha             = DateTime.Today.ToString();//Dia/Mes/Año : Hora
         string hora_de_cancelacion = DateTime.Now.ToLongTimeString();
         string datos = "[Código : " + txtCodigoCancelacion.Text + "] [Producto cancelado : " + txtDescripcionCancelacion.Text + "] [Motivo : " + txtMotivoDeCancelacion.Text + "] [Devolución de efectivo : " + txtTotalDeCancelacion.Text + "] [Hora de cancelacion : " + hora_de_cancelacion + "]";
         string query = "INSERT INTO Cancelacion (Id, Motivo, Fecha, IdUsuario, IdVenta) VALUES (@Id,@Motivo,@Fecha,@IdUsuario,@IdVenta)";
         if (connection.AgregarCancelacion(query, id, datos, mifecha, idUsuario, 1) > 0)
         {
             MessageBox.Show("Cancelacion Exitosa", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Question);
             ViewTabs v = new ViewTabs();
         }
         else
         {
             MessageBox.Show("Cancelacion Fallida", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         connection.CerrarConexion();
         this.Hide();
     }
 }
        private void BtnAddAceptarP_Click(object sender, EventArgs e)
        {
            Connection connection = new Connection();

            if (tBoxAddClaveP.Text.Equals("") || tBoxAddClaveF.Text.Equals("") || tBoxAddCostoP.Text.Equals("") || tBoxAddMarca.Text.Equals("") ||
                tBoxAddDescripcion.Text.Equals("") || tBoxAddCantidadP.Text.Equals("") || cBoxAddCategoriaP.Text.Equals(""))
            {
                MessageBox.Show("No se permiten datos vacios", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                if (Convert.ToDouble(tBoxAddCostoP.Text) <= 0)
                {
                    MessageBox.Show("No se permiten cantidades menores o igual a 0", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    string pesos = "pesos";
                    connection.AbrirConexion();
                    int idCategoria = connection.IdCategoria("SELECT Id From Categoria WHERE Nombre = '" + cBoxAddCategoriaP.Text + "'");
                    connection.CerrarConexion();
                    connection.AbrirConexion();
                    int newId = connection.idProducto("SELECT MAX(Id)+1 FROM Producto");
                    connection.CerrarConexion();
                    connection.AbrirConexion();
                    int filas = connection.ingresarDatos("INSERT INTO Producto (Id,ClaveProducto, ClaveFabricante, Marca, IdCategoria, Descripcion, Costo, Moneda, Cantidad) VALUES (" + newId + ",'" + tBoxAddClaveP.Text + "', '" + tBoxAddClaveF.Text + "', '" + tBoxAddMarca.Text + "', " + idCategoria + ", '" + tBoxAddDescripcion.Text + "', " + Convert.ToDouble(tBoxAddCostoP.Text) + ", '" + pesos + "', " + Convert.ToInt32(tBoxAddCantidadP.Text) + ")");
                    if (filas > 0)
                    {
                        MessageBox.Show("El producto se agrego correctamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                    }
                    connection.CerrarConexion();
                }
            }
        }
        public decimal UltimoIdIngresado()
        {
            Connection connection = new Connection();

            connection.AbrirConexion();
            decimal idCancelacion = connection.generarId("SELECT MAX(Id) FROM Cancelacion");

            if (idCancelacion == 0)
            {
                idCancelacion = 1;
            }
            return(idCancelacion);
        }
Exemple #5
0
        private void btnCobrarVentaNI_Click(object sender, System.EventArgs e)
        {
            int      idVenta = 0;
            DateTime date    = DateTime.Now;

            if (dineroRecibido < totalAPagar)
            {
                MessageBox.Show("No cumple con el pago total");
            }
            else
            {
                MessageBox.Show("LA VENTA SE REALIZO EXITOSAMENTE");
                connection.AbrirConexion();
                idVenta = connection.generarId("Select MAX(Id) from Venta");
                connection.CerrarConexion();
                connection.AbrirConexion();
                connection.guardarVenta("INSERT INTO Venta Values (" + idVenta + "," + idUsuario + ",'" + date + "'," + totalAPagar + ")");
                connection.CerrarConexion();
                this.Hide();
            }
            //this.Hide();
        }
        public AddProduct()
        {
            InitializeComponent();
            DataTable dt = new DataTable();

            connection.AbrirConexion();
            SqlDataAdapter da = connection.consultaMasDatos("select Id, Nombre from Categoria");

            da.Fill(dt);
            connection.CerrarConexion();
            cBoxAddCategoriaP.DisplayMember = "Nombre";
            cBoxAddCategoriaP.ValueMember   = "Id";
            cBoxAddCategoriaP.DataSource    = dt;
        }
        public void consultaSeleccionarCliente()
        {
            Connection connection = new Connection();

            connection.AbrirConexion();
            SqlDataReader dataReader = connection.consulta("SELECT Nombre,Apellido,Telefono,Contacto FROM Cliente WHERE Id=" + idCliente);

            if (dataReader.Read())
            {
                txtNombreCliente.Text   = Convert.ToString(dataReader["Nombre"]);
                txtApellidoCliente.Text = Convert.ToString(dataReader["Apellido"]);
                txtTelefonoCliente.Text = Convert.ToString(dataReader["Telefono"]);
                txtContactoCliente.Text = Convert.ToString(dataReader["Contacto"]);
            }
            connection.CerrarConexion();
        }
        public decimal GenerarId()
        {
            Connection conexion = new Connection();
            Random     random   = new Random();

            conexion.AbrirConexion();
            decimal idR = random.Next(0, 1000000000);

            do
            {
                idR = random.Next(0, 1000000000);
                if (!conexion.VerificarExistenciaDeId(idR))
                {
                    break;
                }
            } while (true);
            conexion.CerrarConexion();
            return(idR);
        }
        public DatosCliente(int id)
        {
            InitializeComponent();
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            Connection connection = new Connection();

            connection.AbrirConexion();
            SqlDataReader dataReader = connection.consulta("SELECT Nombre,Apellido,Telefono,Contacto FROM Cliente WHERE Id=" + id);

            if (dataReader.Read())
            {
                txtNombreCliente.Text   = Convert.ToString(dataReader["Nombre"]);
                txtApellidoCliente.Text = Convert.ToString(dataReader["Apellido"]);
                txtTelefonoCliente.Text = Convert.ToString(dataReader["Telefono"]);
                txtContactoCliente.Text = Convert.ToString(dataReader["Contacto"]);
            }
            connection.CerrarConexion();
            idCliente = id;
        }
Exemple #10
0
        public DatosPieza(int id)
        {
            InitializeComponent();
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            Connection connection = new Connection();

            connection.AbrirConexion();
            SqlDataReader dataReader = connection.consulta("SELECT Descripcion,Estado,FechaEncargada,FechaLlegaAprox FROM Pieza WHERE Id=" + id);

            if (dataReader.Read())
            {
                txtDescPieza.Text     = Convert.ToString(dataReader["Descripcion"]);
                cBoxEstadosPieza.Text = Convert.ToString(dataReader["Estado"]);
                txtFechaPPieza.Text   = Convert.ToString(dataReader["FechaEncargada"]);
                txtFechaLPieza.Text   = Convert.ToString(dataReader["FechaLlegaAprox"]);
            }
            idPieza = id;
            connection.CerrarConexion();
        }
        private void btnAceptarCliente_Click(object sender, EventArgs e)
        {
            Connection connection = new Connection();

            if (btnAceptarCliente.Text.Equals("Aceptar"))
            {
                this.Hide();
            }
            if (btnAceptarCliente.Text.Equals("Guardar"))
            {
                if (txtNombreCliente.Text.Equals("") || txtApellidoCliente.Text.Equals("") ||
                    txtTelefonoCliente.Text.Equals("") || txtContactoCliente.Text.Equals(""))
                {
                    MessageBox.Show("No se permiten espacios vacios", "Advertencia");
                }
                else
                {
                    connection.AbrirConexion();
                    DialogResult resultado = MessageBox.Show("Esta seguro que desea guardar los cambios", "Seguridad", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (resultado == DialogResult.Yes)
                    {
                        connection.modificarCliente("UPDATE Cliente SET Nombre='" + txtNombreCliente.Text + "', Apellido='" + txtApellidoCliente.Text + "', " +
                                                    "Telefono='" + txtTelefonoCliente.Text + "', Contacto='" + txtContactoCliente.Text + "' WHERE Id=" + idCliente);
                        MessageBox.Show("Los datos se han cambiado correctamente");
                        consultaSeleccionarCliente();
                        btnAceptarCliente.Text = "Aceptar";
                        inhabilitarTxtBox();
                        this.Hide();
                    }
                    else
                    {
                        consultaSeleccionarCliente();
                        inhabilitarTxtBox();
                        btnAceptarCliente.Text = "Guardar";
                    }
                    connection.CerrarConexion();
                }
            }
        }
Exemple #12
0
        private void BtnAceptarPieza_Click(object sender, EventArgs e)
        {
            Connection connection = new Connection();

            connection.AbrirConexion();
            if (BtnAceptarPieza.Text.Equals("Aceptar"))
            {
                this.Hide();
            }
            if (BtnAceptarPieza.Text.Equals("Guardar"))
            {
                DialogResult result = MessageBox.Show("Esta seguro que desea cambiar el estado?", "Informacion", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    int filas = connection.actualizarDatos("UPDATE Pieza SET Estado='" + cBoxEstadosPieza.Text + "' WHERE Id=" + idPieza);
                    MessageBox.Show("Los datos se actualizaron correctamente");
                    BtnAceptarPieza.Text     = "Aceptar";
                    btnCancelarPieza.Visible = false;
                    this.Hide();
                }
            }
            connection.CerrarConexion();
        }
Exemple #13
0
        private void btnCancelarPieza_Click(object sender, EventArgs e)
        {
            Connection connection = new Connection();

            connection.AbrirConexion();
            DialogResult result = MessageBox.Show("Esta seguro que desea cancelar la modificacion?", "Informacion", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                SqlDataReader dataReader = connection.consulta("SELECT Descripcion,Estado,FechaEncargada,FechaLlegaAprox FROM Pieza WHERE Id=" + idPieza);
                if (dataReader.Read())
                {
                    txtDescPieza.Text        = Convert.ToString(dataReader["Descripcion"]);
                    cBoxEstadosPieza.Text    = Convert.ToString(dataReader["Estado"]);
                    txtFechaPPieza.Text      = Convert.ToString(dataReader["FechaEncargada"]);
                    txtFechaLPieza.Text      = Convert.ToString(dataReader["FechaLlegaAprox"]);
                    cBoxEstadosPieza.Enabled = false;
                    btnCancelarPieza.Visible = false;
                    BtnAceptarPieza.Text     = "Aceptar";
                }
                MessageBox.Show("Cancelacion exitosa");
            }
            connection.CerrarConexion();
        }
 private void NICtxtConfirmarContrasenaU_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (Char)Keys.Enter)
     {
         if (NICtxtNombreUsuario.Text.Equals("NOMBRE DE USUARIO") || NICtxtNombreU.Text.Equals("NOMBRE") || NICtxtApellidoU.Text.Equals("NOMBRE") || NICtxtCorreoU.Text.Equals("CORREO") ||
             NiCtxtTelefonoU.Text.Equals("TELEFONO") || NICtxtContrasenaU.Text.Equals("CONTRASEÑA") || NICtxtConfirmarContrasenaU.Text.Equals("CONFIRMAR CONTRASEÑA"))
         {
             MessageBox.Show("NO SE PUEDE AGREGAR UN NUEVO USUARIO POR LA EXISTENCIA DE CAMPOS VACIOS", "ERROR DE CAMPOS", MessageBoxButtons.OK, MessageBoxIcon.Question);
         }
         else
         {
             NICtxtNombreUsuario.Text = NICtxtNombreUsuario.Text.ToUpper();
             string usuario = NICtxtNombreUsuario.Text.ToUpper();
             if (validarEmail(NICtxtCorreoU.Text))
             {
                 if (NICtxtContrasenaU.Text == NICtxtConfirmarContrasenaU.Text)
                 {
                     Connection conexion = new Connection();
                     conexion.AbrirConexion();
                     if (!(conexion.ExisteUsuario(NICtxtNombreUsuario.Text.ToUpper())))
                     {
                         decimal id     = GenerarId();
                         string  coe    = Controllers.Encrypt.GetMD5(NICtxtContrasenaU.Text);
                         String  _query = "INSERT INTO Usuario (Id,NombreUsuario,Nombre,Apellido,Telefono,Correo,Contra,Rol) VALUES (" + id + ",'" + NICtxtNombreUsuario.Text + "','" + NICtxtNombreU.Text + "','" + NICtxtApellidoU.Text + "','" + NiCtxtTelefonoU.Text + "','" + NICtxtCorreoU.Text + "','" + coe + "','Trabajador')";
                         conexion.AddElements(_query, "usuario");
                         //------------------------------------------------
                         DialogResult resultado = MessageBox.Show("¿Desea agregar otro usuario?", "Nuevo Usuario", MessageBoxButtons.YesNo);
                         if (resultado == DialogResult.Yes)
                         {
                             NICtxtNombreUsuario.Text        = "NOMBRE DE USUARIO";
                             NICtxtNombreU.Text              = "NOMBRE";
                             NICtxtApellidoU.Text            = "NOMBRE";
                             NiCtxtTelefonoU.Text            = "TELEFONO";
                             NICtxtCorreoU.Text              = "CORREO";
                             NICtxtContrasenaU.Text          = "CONTRASEÑA";
                             NICtxtConfirmarContrasenaU.Text = "CONFIRMAR CONTRASEÑA";
                         }
                         else if (resultado == DialogResult.No)
                         {
                             this.Hide();
                         }
                         conexion.CerrarConexion();
                     }
                     else
                     {
                         MessageBox.Show("NO SE PUEDE AGREGAR UN NUEVO USUARIO PORQUE EL NOMBRE DE USUARIO YA EXISTE", "NOMBRE DE USUARIO INVALIDO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                         NICtxtNombreUsuario.Text = "";
                     }
                 }
                 else
                 {
                     MessageBox.Show("LOS CAMPOS DE CONTRASEÑAS NO SON IGUALES", "NO COINCIDENCIAS", MessageBoxButtons.OK, MessageBoxIcon.Question);
                     NICtxtContrasenaU.Text          = "CONTRASEÑA";
                     NICtxtConfirmarContrasenaU.Text = "CONFIRMAR CONTRASEÑA";
                 }
             }
             else
             {
                 MessageBox.Show("NO SE PUEDE AGREGAR UN NUEVO USUARIO PORQUE EL FORMATO DE CORREO ES INVALIDO", "FORMATO NO VALIDO", MessageBoxButtons.OK, MessageBoxIcon.Question);
             }
         }
     }
 }