Esempio n. 1
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            frmDepartamentos user     = new frmDepartamentos();
            DialogResult     pregunta = MessageBox.Show("¿Deseas eliminar el departamento " + txtId.Text + "?");

            if (pregunta == DialogResult.OK)
            {
                SqlCommand cmd = new SqlCommand("delete from departamento where id_departamento = " + txtId.Text + "", xSQL.conn);

                try
                {
                    xSQL.conn.Open();
                    cmd.ExecuteNonQuery();
                    Mensajes.Aviso("Registro eliminado con éxito ");
                }
                catch (Exception ex)
                {
                    Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
                }
                finally
                {
                    xSQL.conn.Close();
                    this.Close();
                    user.Show();
                }
            }
            else
            {
                this.Close();
                user.Show();
            }
        }
Esempio n. 2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            frmUsuarios user = new frmUsuarios();

            if (txtContrasena.Text != txtConfirmar.Text)
            {
                Mensajes.Aviso("No coinciden las contraseñas.\n Vuelve a intentarlo");
            }
            else
            {
                SqlCommand cmd = new SqlCommand("SP_Inserta_usuario", xSQL.conn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter folio = new SqlParameter("@nId", SqlDbType.Int);
                folio.Direction = ParameterDirection.InputOutput;
                folio.Value     = Convert.ToInt32(txtId.Text);
                cmd.Parameters.Add(folio);

                SqlParameter nombre = new SqlParameter("@cNombre", SqlDbType.VarChar, 50);
                nombre.Value = txtUsuario.Text;
                cmd.Parameters.Add(nombre);

                SqlParameter contrasena = new SqlParameter("@cContrasena", SqlDbType.VarChar, 50);
                contrasena.Value = Encriptador.RijndaelSimple.EncryptKey(txtContrasena.Text);
                cmd.Parameters.Add(contrasena);

                SqlParameter estado = new SqlParameter("@cEstatus", SqlDbType.VarChar, 20);
                estado.Value = "Activo";
                cmd.Parameters.Add(estado);

                SqlParameter admin = new SqlParameter("@bEs_Administrador", SqlDbType.Bit);
                admin.Value = chkAdministrador.Checked;
                cmd.Parameters.Add(admin);

                try
                {
                    xSQL.conn.Open();
                    cmd.ExecuteNonQuery();
                    Mensajes.Aviso("Registro modificado con éxito ");
                }
                catch (Exception ex)
                {
                    Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
                }
                finally
                {
                    xSQL.conn.Close();
                    this.Close();
                    user.Show();
                }
            }
        }
Esempio n. 3
0
        private void AbrirTurno()
        {
            string  sMac  = Generales.MacAdress();
            Boolean bPasa = false;

            SqlCommand SP = new SqlCommand("valida_Caja", xSQL.conn);

            SP.CommandType = CommandType.StoredProcedure;

            SqlParameter sqlMac = new SqlParameter("@cMac", SqlDbType.VarChar);

            sqlMac.Value = sMac;
            SP.Parameters.Add(sqlMac);


            SqlParameter sqlPasa = new SqlParameter("@bPasa", SqlDbType.Bit);

            sqlPasa.Direction = ParameterDirection.Output;
            SP.Parameters.Add(sqlPasa);

            try
            {
                xSQL.conn.Open();
                SP.ExecuteNonQuery();

                bPasa = (Boolean)sqlPasa.Value;

                if (!bPasa)
                {
                    Mensajes.Error("Este equipo no está registrado como caja");
                }
                else
                {
                    Mensajes.Aviso("Turno Abierto");
                }
            }
            catch (Exception ex)
            {
                Mensajes.Error("Se ha producido un error: \n" + ex.Message);
            }
            finally
            {
                xSQL.conn.Close();
            }
        }
Esempio n. 4
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     if (chkSeguridad.Checked)
     {
         Cadena.escribirDatosSeguridad(txtServidor.Text, txtBase.Text);
         try
         {
             xSQL.conn.Open();
             Mensajes.Aviso("Conexión éxitosa");
             this.Close();
             frmConfiguracion conf = new frmConfiguracion();
             conf.Show();
         }
         catch (Exception ex)
         {
             Mensajes.Error("Fallo la conexión \n" + ex.Message);
         }
         finally
         {
             xSQL.conn.Close();
         }
     }
     else
     {
         Cadena.guardarDatos(txtServidor.Text, txtBase.Text, txtUsuario.Text, txtContrasena.Text);
         try
         {
             xSQL.conn.Open();
             Mensajes.Aviso("Conexión éxitosa");
             this.Close();
             frmConfiguracion conf = new frmConfiguracion();
             conf.Show();
         }
         catch (Exception ex)
         {
             Mensajes.Error("Fallo la conexión \n" + ex.Message);
         }
         finally
         {
             xSQL.conn.Close();
         }
     }
 }
Esempio n. 5
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("SP_Inserta_Mac", xSQL.conn);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter folio = new SqlParameter("@nId", SqlDbType.Int);

            folio.Direction = ParameterDirection.InputOutput;
            folio.Value     = 0;
            cmd.Parameters.Add(folio);

            SqlParameter mac = new SqlParameter("@cMac", SqlDbType.VarChar, 20);

            mac.Value = txtMac.Text;
            cmd.Parameters.Add(mac);

            SqlParameter nombre = new SqlParameter("@cNombre", SqlDbType.VarChar, 20);

            nombre.Value = txtNombre.Text;
            cmd.Parameters.Add(nombre);


            try
            {
                xSQL.conn.Open();
                cmd.ExecuteNonQuery();
                Mensajes.Aviso("Registro guardado con éxito ");
            }
            catch (Exception ex)
            {
                Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
            }
            finally
            {
                xSQL.conn.Close();
                this.Close();
                frmConfiguracion conf = new frmConfiguracion();
                conf.Show();
            }
        }
Esempio n. 6
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("INSERT INTO departamento (nombre) values('" + txtDepartamento.Text + "')", xSQL.conn);

            try
            {
                xSQL.conn.Open();
                cmd.ExecuteNonQuery();
                Mensajes.Aviso("Registro guardado con éxito ");
            }
            catch (Exception ex)
            {
                Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
            }
            finally
            {
                xSQL.conn.Close();
                this.Close();
                frmConfiguracion conf = new frmConfiguracion();
                conf.Show();
            }
        }
Esempio n. 7
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("update Departamento set nombre = '" + txtDepartamento.Text + "'  where id_departamento = " + txtId.Text + "", xSQL.conn);

            try
            {
                xSQL.conn.Open();
                cmd.ExecuteNonQuery();
                Mensajes.Aviso("Registro modificado con éxito ");
            }
            catch (Exception ex)
            {
                Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
            }
            finally
            {
                xSQL.conn.Close();
                this.Close();
                frmConfiguracion conf = new frmConfiguracion();
                conf.Show();
            }
        }
Esempio n. 8
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            frmUsuarios  user     = new frmUsuarios();
            DialogResult pregunta = MessageBox.Show("¿Deseas eliminar el usuario " + txtId.Text + "?");

            if (pregunta == DialogResult.OK)
            {
                SqlCommand cmd = new SqlCommand("SP_Borra_usuario", xSQL.conn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter folio = new SqlParameter("@idusuario", SqlDbType.Int);
                folio.Value = Convert.ToInt32(txtId.Text);
                cmd.Parameters.Add(folio);

                try
                {
                    xSQL.conn.Open();
                    cmd.ExecuteNonQuery();
                    Mensajes.Aviso("Registro eliminado con éxito ");
                }
                catch (Exception ex)
                {
                    Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
                }
                finally
                {
                    xSQL.conn.Close();
                    this.Close();
                    user.Show();
                }
            }
            else
            {
                this.Close();
                user.Show();
            }
        }
Esempio n. 9
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            obteneridDepartamento();
            SqlCommand cmd = new SqlCommand("SP_Inserta_Producto", xSQL.conn);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter folio = new SqlParameter("@nIdProducto", SqlDbType.Int);

            folio.Direction = ParameterDirection.InputOutput;
            folio.Value     = Convert.ToInt32(txtId.Text);
            cmd.Parameters.Add(folio);

            SqlParameter nombre = new SqlParameter("@cProducto", SqlDbType.VarChar, 50);

            nombre.Value = txtProducto.Text;
            cmd.Parameters.Add(nombre);

            SqlParameter departamento = new SqlParameter("@nDepartamento", SqlDbType.Int);

            departamento.Value = Convert.ToInt32(idDepa);
            cmd.Parameters.Add(departamento);

            SqlParameter barras = new SqlParameter("@cCodBarras", SqlDbType.VarChar, 50);

            barras.Value = txtBarras.Text;
            cmd.Parameters.Add(barras);

            SqlParameter cuenta = new SqlParameter("@bSeCuenta", SqlDbType.Bit);

            cuenta.Value = chkCuenta.Checked;
            cmd.Parameters.Add(cuenta);

            SqlParameter clave = new SqlParameter("@cClave", SqlDbType.VarChar, 50);

            clave.Value = txtClave.Text;
            cmd.Parameters.Add(clave);

            SqlParameter interes = new SqlParameter("@nTasaInteres", SqlDbType.Decimal);

            interes.Value = txtImpuesto.Text;
            cmd.Parameters.Add(interes);

            SqlParameter precio = new SqlParameter("@nPrecio", SqlDbType.Money);

            precio.Value = txtPrecio.Text;
            cmd.Parameters.Add(precio);
            try
            {
                xSQL.conn.Open();
                cmd.ExecuteNonQuery();
                Mensajes.Aviso("Registro modificado con éxito ");
            }
            catch (Exception ex)
            {
                Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
            }
            finally
            {
                xSQL.conn.Close();
                this.Close();
                frmConfiguracion conf = new frmConfiguracion();
                conf.Show();
            }
        }
Esempio n. 10
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("SP_Inserta_Cliente", xSQL.conn);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter folio = new SqlParameter("@nId", SqlDbType.Int);

            folio.Direction = ParameterDirection.InputOutput;
            folio.Value     = Convert.ToInt32(txtId.Text);;
            cmd.Parameters.Add(folio);

            SqlParameter nombre = new SqlParameter("@cNombre", SqlDbType.VarChar, 50);

            nombre.Value = txtUsuario.Text;
            cmd.Parameters.Add(nombre);

            SqlParameter paterno = new SqlParameter("@cApaterno", SqlDbType.VarChar, 50);

            paterno.Value = txtPaterno.Text;
            cmd.Parameters.Add(paterno);

            SqlParameter materno = new SqlParameter("@cAmaterno", SqlDbType.VarChar, 50);

            materno.Value = txtMaterno.Text;
            cmd.Parameters.Add(materno);

            SqlParameter telefono = new SqlParameter("@cTelefono", SqlDbType.VarChar, 50);

            telefono.Value = txtTelefono.Text;
            cmd.Parameters.Add(telefono);

            SqlParameter celular = new SqlParameter("@cCelular", SqlDbType.VarChar, 50);

            celular.Value = txtCelular.Text;
            cmd.Parameters.Add(celular);

            SqlParameter direccion = new SqlParameter("@cDireccion", SqlDbType.VarChar, 80);

            direccion.Value = txtDireccion.Text;
            cmd.Parameters.Add(direccion);

            SqlParameter estado = new SqlParameter("@cEstatus", SqlDbType.VarChar, 20);

            estado.Value = txtEstado.Text;
            cmd.Parameters.Add(estado);

            SqlParameter limite = new SqlParameter("@mLimCredito", SqlDbType.Money);

            limite.Value = txtLimite.Text;
            cmd.Parameters.Add(limite);

            try
            {
                xSQL.conn.Open();
                cmd.ExecuteNonQuery();
                Mensajes.Aviso("Registro guardado con éxito ");
            }
            catch (Exception ex)
            {
                Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
            }
            finally
            {
                xSQL.conn.Close();
                this.Close();
                frmConfiguracion conf = new frmConfiguracion();
                conf.Show();
            }
        }
Esempio n. 11
0
        private void pbOk_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("SP_Inserta_venta", xSQL.conn);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter folio = new SqlParameter("@nId", SqlDbType.Int);

            folio.Direction = ParameterDirection.InputOutput;
            folio.Value     = 0;
            cmd.Parameters.Add(folio);

            SqlParameter caja = new SqlParameter("@nCaja", SqlDbType.Int);

            caja.Value = Generales.cajaActual;
            cmd.Parameters.Add(caja);

            SqlParameter cajero = new SqlParameter("@nCajero", SqlDbType.Int);

            cajero.Value = Generales.cajeroActual;
            cmd.Parameters.Add(cajero);

            SqlParameter subtotal = new SqlParameter("@nSubtotal", SqlDbType.VarChar, 50);

            subtotal.Value = txtsubtotal.Text;
            cmd.Parameters.Add(subtotal);

            SqlParameter impuesto = new SqlParameter("@nImpuesto", SqlDbType.VarChar, 50);

            impuesto.Value = txtImpuesto.Text;
            cmd.Parameters.Add(impuesto);

            SqlParameter total = new SqlParameter("@nTotal", SqlDbType.VarChar, 50);

            total.Value = txtTotal.Text;
            cmd.Parameters.Add(total);

            SqlParameter fecha = new SqlParameter("@sFecha", SqlDbType.DateTime);

            fecha.Value = DateTime.Now;
            cmd.Parameters.Add(fecha);

            try
            {
                xSQL.conn.Open();
                cmd.ExecuteNonQuery();
                Mensajes.Aviso("Venta registrada con éxito");
            }
            catch (Exception ex)
            {
                Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
            }
            finally
            {
                xSQL.conn.Close();
                dgvVenta.Rows.Clear();
                txtsubtotal.Text = "";
                txtImpuesto.Text = "";
                txtTotal.Text    = "";
            }
        }
Esempio n. 12
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            string estado = "";

            revisarRegistro();
            revisarTurno();
            if (registrado)
            {
                estado = "Activo";
            }
            else
            {
                estado = "Iniactivo";
            }
            Generales.caja();
            Generales.turnoActual = cbTurnos.SelectedItem.ToString();

            SqlCommand cmd = new SqlCommand("SP_Inserta_Turno", xSQL.conn);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter folio = new SqlParameter("@nId", SqlDbType.Int);

            folio.Direction = ParameterDirection.InputOutput;
            folio.Value     = 0;
            cmd.Parameters.Add(folio);

            SqlParameter fechaInicial = new SqlParameter("@cFechaInicial", SqlDbType.DateTime);

            fechaInicial.Value = DateTime.Now;
            cmd.Parameters.Add(fechaInicial);

            SqlParameter fechaFinal = new SqlParameter("@cFechaFinal", SqlDbType.DateTime);

            fechaFinal.Value = DateTime.Now;
            cmd.Parameters.Add(fechaFinal);

            SqlParameter caja = new SqlParameter("@nCaja", SqlDbType.Int);

            caja.Value = Generales.cajaActual;
            cmd.Parameters.Add(caja);

            SqlParameter cajero = new SqlParameter("@nCajero", SqlDbType.Int);

            cajero.Value = Generales.cajeroActual;
            cmd.Parameters.Add(cajero);

            SqlParameter montoInicial = new SqlParameter("@nMontoInicial", SqlDbType.Decimal);

            montoInicial.Value = Convert.ToInt32(txtMontoInicial.Text);
            cmd.Parameters.Add(montoInicial);

            SqlParameter montoFinal = new SqlParameter("@nMontoFinal", SqlDbType.Decimal);

            montoFinal.Value = 0;
            cmd.Parameters.Add(montoFinal);

            SqlParameter estadoActual = new SqlParameter("@cEstado", SqlDbType.VarChar, 50);

            estadoActual.Value = estado;
            cmd.Parameters.Add(estadoActual);

            SqlParameter tipo = new SqlParameter("@cTipo", SqlDbType.VarChar, 50);

            tipo.Value = cbTurnos.SelectedItem.ToString();
            cmd.Parameters.Add(tipo);

            try
            {
                if (estadoTurno == true)
                {
                    Mensajes.Aviso("Bienvenido, ya tienes un turno abierto");
                }
                else
                {
                    xSQL.conn.Open();
                    cmd.ExecuteNonQuery();
                    Mensajes.Aviso("Bienvenido ");
                }
            }
            catch (Exception ex)
            {
                Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
            }
            finally
            {
                if (estadoTurno)
                {
                    Form1 menu = new Form1();
                    menu.Show();
                    menu.lblUsuario.Text = Generales.sUsuario;
                    this.Hide();
                }
                else
                {
                    xSQL.conn.Close();
                    Form1 menu = new Form1();
                    menu.Show();
                    menu.lblUsuario.Text = Generales.sUsuario;
                    this.Hide();
                }
            }
        }
Esempio n. 13
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (cbTipo.SelectedItem.ToString() == "Temporal")
            {
                xSQL.conn.Open();
                SqlCommand cmd = new SqlCommand("update turnos set estado_actual = 'Bloqueado' where caja = " + Generales.cajaActual + " and cajero = " + Generales.cajeroActual + "", xSQL.conn);
                cmd.ExecuteNonQuery();
                xSQL.conn.Close();
                frmBloqueado bloqueado = new frmBloqueado();
                bloqueado.Show();
                this.Hide();
            }
            else
            {
                idTurno();
                SqlCommand cmd = new SqlCommand("SP_Inserta_Turno", xSQL.conn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter folio = new SqlParameter("@nId", SqlDbType.Int);
                folio.Direction = ParameterDirection.InputOutput;
                folio.Value     = turno;
                cmd.Parameters.Add(folio);

                SqlParameter fechaInicial = new SqlParameter("@cFechaInicial", SqlDbType.DateTime);
                fechaInicial.Value = null;
                cmd.Parameters.Add(fechaInicial);

                SqlParameter fechaFinal = new SqlParameter("@cFechaFinal", SqlDbType.DateTime);
                fechaFinal.Value = DateTime.Now;
                cmd.Parameters.Add(fechaFinal);

                SqlParameter caja = new SqlParameter("@nCaja", SqlDbType.Int);
                caja.Value = Generales.cajaActual;
                cmd.Parameters.Add(caja);

                SqlParameter cajero = new SqlParameter("@nCajero", SqlDbType.Int);
                cajero.Value = Generales.cajeroActual;
                cmd.Parameters.Add(cajero);

                SqlParameter montoInicial = new SqlParameter("@nMontoInicial", SqlDbType.Decimal);
                montoInicial.Value = 0;
                cmd.Parameters.Add(montoInicial);

                SqlParameter montoFinal = new SqlParameter("@nMontoFinal", SqlDbType.Decimal);
                montoFinal.Value = Convert.ToInt32(txtMontoFinal.Text);
                cmd.Parameters.Add(montoFinal);

                SqlParameter estadoActual = new SqlParameter("@cEstado", SqlDbType.VarChar, 50);
                estadoActual.Value = "Cerrado";
                cmd.Parameters.Add(estadoActual);

                SqlParameter tipo = new SqlParameter("@cTipo", SqlDbType.VarChar, 50);
                tipo.Value = "";
                cmd.Parameters.Add(tipo);

                try
                {
                    xSQL.conn.Open();
                    cmd.ExecuteNonQuery();
                    Mensajes.Aviso("Hasta luego ");
                }
                catch (Exception ex)
                {
                    Mensajes.Error("A ocurrido un error en el sistema, " + ex.Message);
                }
                finally
                {
                    xSQL.conn.Close();
                    Application.Exit();
                }
            }
        }