Beispiel #1
0
        private void bAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                conexion.Open();
                if (!this.hayAlgunTextboxVacio(tDNI, tNombre, tApellido, tMail, tDireccion, tTelefono, cProvincia, cTipo, cSucursal, cHabilitado))
                {
                    String[,] parametros = new String[2, 10];
                    String sp = "mayusculas_sin_espacios.sp_altaEmpleado";
                    parametros[0, DNI]        = "@DNI";
                    parametros[0, NOMBRE]     = "@Nombre";
                    parametros[0, APELLIDO]   = "@Apellido";
                    parametros[0, MAIL]       = "@Mail";
                    parametros[0, DIRECCION]  = "@direccion";
                    parametros[0, TELEFONO]   = "@telefono";
                    parametros[0, PROVINCIA]  = "@provincia";
                    parametros[0, TIPO]       = "@tipo";
                    parametros[0, SUCURSAL]   = "@sucursal";
                    parametros[0, HABILITADO] = "@habilitado";

                    parametros[1, DNI]        = tDNI.Text;
                    parametros[1, NOMBRE]     = tNombre.Text;
                    parametros[1, APELLIDO]   = tApellido.Text;
                    parametros[1, MAIL]       = tMail.Text;
                    parametros[1, DIRECCION]  = tDireccion.Text;
                    parametros[1, TELEFONO]   = tTelefono.Text;
                    parametros[1, PROVINCIA]  = cProvincia.SelectedIndex.ToString();
                    parametros[1, TIPO]       = cTipo.SelectedIndex.ToString();
                    parametros[1, SUCURSAL]   = cSucursal.SelectedIndex.ToString();
                    parametros[1, HABILITADO] = System.Convert.ToInt32(cHabilitado.Checked).ToString();


                    SqlDataReader reader = conexion.ejecutarStoredProcedure(sp, parametros);
                    if (reader != null)
                    {
                        MessageBox.Show("Se ha dado de alta el Empleado.", "Success!");
                        this.limpiar();
                    }
                }
                else
                {
                    MessageBox.Show("Debe completar todos los campos", "Warning!");
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "Error!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, "Error app");
            }
            finally
            {
                conexion.Close();
            }
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUser.Text != "")
            {
                sql.Open();

                String procedureName = ClaseSQL.tableName("sp_LOGIN");
                String[,] parametros = new String[2, 2];
                parametros[0, 0]     = "@USERNAME";
                parametros[0, 1]     = "@PASS";
                parametros[1, 0]     = txtUser.Text;
                parametros[1, 1]     = hasher.hash(txtPass.Text);

                SqlDataReader otroReader = sql.ejecutarStoredProcedure(procedureName, parametros);
                if (otroReader.Read())
                {
                    switch (otroReader[0].ToString())
                    {
                    case "USUARIO BLOQUEADO":
                        MessageBox.Show("USUARIO BLOQUEADO");
                        break;

                    case "CONTRASEÑA INVALIDA":
                        MessageBox.Show("CONTRASEÑA INVALIDA");
                        break;

                    case "NO EXISTE EN LA BASE":
                        MessageBox.Show("NO EXISTE EN LA BASE");
                        break;

                    default:
                        int i = 0;
                        do
                        {
                            funciones[i] = otroReader[0].ToString();
                            i++;
                            correcto = true;
                            username = txtUser.Text.ToLower();
                        } while (otroReader.Read());
                        break;
                    }
                }
                else
                {
                    correcto = true;
                    username = txtUser.Text.ToLower();
                }
                otroReader.Close();
                sql.Close();
            }
            else
            {
                MessageBox.Show("Campo Username Vacio");
            }
            //Si el Login es correcto cierra el formulario y continua con el Formulario Principal
            if (correcto)
            {
                this.Close();
            }
        }
Beispiel #3
0
        private void actualizarRoles()
        {
            for (int i = 0; i < dgRoles.RowCount; i++)
            {
                String[,] parametros = new String[2, 3];
                String sp = "mayusculas_sin_espacios.[sp_asignacion]";
                parametros[0, 0] = "@user";
                parametros[0, 1] = "@rol";
                parametros[0, 2] = "@habilitado";

                parametros[1, 0] = tNombre.Text.ToString();
                parametros[1, 1] = dgRoles.Rows[i].Cells["Codigo"].Value.ToString();
                parametros[1, 2] = (System.Convert.ToInt32(dgRoles.Rows[i].Cells["Seleccion"].Value)).ToString();

                SqlDataReader reader = conexion.ejecutarStoredProcedure(sp, parametros);
                reader.Close();
            }
        }
Beispiel #4
0
        private void rellenarComboBoxFactura()
        {
            cFactura.Items.Clear();
            cFactura.Text = "";

            conexion.Open();
            String[,] parametros = new String[2, 1];
            String sp = "mayusculas_sin_espacios.sp_FACTURASPENDIENTES";

            parametros[0, 0] = "@cliente";
            parametros[1, 0] = tCliente.Text;

            SqlDataReader reader = conexion.ejecutarStoredProcedure(sp, parametros);

            while (reader.Read())
            {
                String fact = reader[0].ToString().Trim();
                cFactura.Items.Add(fact);
            }
            reader.Close();
            conexion.Close();
        }
        private void consultarClientes()
        {
            String[,] parametros = new String[2, 2];
            String sp = "mayusculas_sin_espacios.sp_MEJORESCATEGORIAS";

            parametros[0, 0] = "@sucursal";
            parametros[0, 1] = "@año";

            parametros[1, 0] = ((Provincia)cSucursal.SelectedItem).codigo.ToString();
            parametros[1, 1] = cAnio.Value.ToString();
            SqlDataReader reader = conexion.ejecutarStoredProcedure(sp, parametros);

            DataTable tabla = new DataTable();

            if (reader.HasRows)
            {
                tabla.Load(reader);
            }
            dgClientes.DataSource = tabla;
            dgClientes.Show();
            reader.Close();
        }
Beispiel #6
0
        private void bComprar_Click(object sender, EventArgs e)
        {
            try
            {
                conexion.Open();
                if (!this.hayAlgunTextboxVacio(cProvincia, cSucursal, tCliente, tDescuento, cCuotas, dgProductos))
                {
                    DialogResult op = MessageBox.Show("El importe total es de $" + this.montoTotal(), "Confirmar", MessageBoxButtons.OKCancel);
                    if (op == DialogResult.OK)
                    {
                        Object[,] parametros = new Object[2, 6];
                        String sp = "mayusculas_sin_espacios.sp_facturar";
                        parametros[0, 0] = "@fecha";
                        parametros[0, 1] = "@descuento";
                        parametros[0, 2] = "@cuotas";
                        parametros[0, 3] = "@sucursal";
                        parametros[0, 4] = "@vendedor";
                        parametros[0, 5] = "@cliente";

                        parametros[1, 0] = DateTime.Now;
                        parametros[1, 1] = tDescuento.Text;
                        parametros[1, 2] = (cCuotas.SelectedIndex + 1).ToString();
                        parametros[1, 3] = (cSucursal.SelectedIndex + 1).ToString();
                        parametros[1, 4] = dni.ToString();
                        parametros[1, 5] = tCliente.Text;


                        SqlDataReader reader = conexion.ejecutarStoredProcedure(sp, parametros);
                        if (reader.Read())
                        {
                            nrofactura = reader[0].ToString();
                            MessageBox.Show("Se ha Facturado - " + nrofactura.ToString(), "Success!");
                        }
                        reader.Close();

                        string sql = "";
                        for (int i = 0; i < dgProductos.Rows.Count - 1; i++)
                        {
                            sql = "insert into mayusculas_sin_espacios.itemsfactura (factura,producto,preciounitario,cantidad) " +
                                  " values ('" + nrofactura + "','" + dgProductos.Rows[i].Cells[0].Value.ToString() +
                                  "','" + dgProductos.Rows[i].Cells[1].Value.ToString() +
                                  "','" + dgProductos.Rows[i].Cells[2].Value.ToString() + "')";
                            conexion.nonQuery(sql);
                            this.limpiarForm();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Debe completar todos los campos", "Warning!");
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "Error!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, "Error app");
            }
            finally
            {
                conexion.Close();
            }
        }