Exemplo n.º 1
0
        //este metodo obtiene el ultimo id ingresado de un cliente
        private int maxId()
        {
            //se declara el entero que sera el id del cliente
            int id = 1;

            try
            {
                //se abre conexion
                Connection.OpenConnection();

                //se declara un reader que tendra el id del cliente
                MySqlDataReader reader = Class.Client.clientMaxId(Connection.myConnection);

                //mientras se haga la consulta
                if (reader.Read())
                {
                    //se valida si la db esta vacia
                    if (!reader.IsDBNull(0))
                    {
                        //se establece el id del cliente a la variable
                        id = reader.GetInt32(0);
                    }
                }

                //se cierra conexion
                Connection.CloseConnection();
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo obtener el id");
            }

            //retornamos el id del cliente
            return(id);
        }
Exemplo n.º 2
0
        private void ModifyEmployee_Load(object sender, EventArgs e)
        {
            Connection.OpenConnection();
            int id = Int32.Parse(idEmployee);

            Class.Employee employee = Class.Employee.searchEmployee(Connection.myConnection, id);
            Connection.CloseConnection();

            idTextBox.Text        = employee.IdEmployee.ToString();
            firstNameTextBox.Text = employee.FirstName;
            lastNameTextBox.Text  = employee.LastName;
            phoneTextBox.Text     = employee.Phone;
            emailTextBox.Text     = employee.Email;
            addressTextBox.Text   = employee.Address;
            passwordTextBox.Text  = employee.Password;

            if (employee.EmployeeType == 0)
            {
                positionComboBox.Text = "Gerente";
            }
            else
            {
                positionComboBox.Text = "Cajero";
            }
        }
Exemplo n.º 3
0
        //metodo cargar de la pagina
        private void ModifyAccount_Load(object sender, EventArgs e)
        {
            //se abre conexion a la db
            Connection.OpenConnection();

            //metodo que busca la cuenta por id
            Class.Account account = Class.Account.searchAccount(Connection.myConnection, idAccount);

            //establecemos los datos en sus respectivos campos para su modificacion
            idAccountTextBox.Text        = Convert.ToString(account.IdAccount);
            idClientTextBox.Text         = Convert.ToString(account.Client_IdClient);
            nipTextBox.Text              = account.Nip;
            balancetextBox.Text          = Convert.ToString(account.Balance);
            maximumCreditTextBox.Text    = Convert.ToString(account.MaximumCredit);
            cutOffDayDateTimePicker.Text = Convert.ToString(account.CutOffDay);

            if (account.AccountType == 0)
            {
                accountTypeComboBox.SelectedItem = "Credito";
            }
            else
            {
                accountTypeComboBox.SelectedItem = "Debito";
            }

            //cierra conexion a la db
            Connection.CloseConnection();
        }
Exemplo n.º 4
0
 private void ModifyClient_Load(object sender, EventArgs e)
 {
     Connection.OpenConnection();
     Class.Client client = Class.Client.searchClient(Connection.myConnection, idClient);
     idTextBox.Text        = Convert.ToString(client.IdClient);
     firstNameTextBox.Text = client.FirstName;
     lastNameTextBox.Text  = client.LastName;
     phoneTextBox.Text     = client.Phone;
     emailtextBox.Text     = client.Email;
     addressTextBox.Text   = client.Address;
     Connection.CloseConnection();
 }
Exemplo n.º 5
0
        public void loadData()
        {
            Connection.OpenConnection();
            clientsGridView.DataSource = Class.Client.showDeletedClients(Connection.myConnection);

            this.clientsGridView.Columns[0].HeaderCell.Value = "ID";
            this.clientsGridView.Columns[1].HeaderCell.Value = "Nombre";
            this.clientsGridView.Columns[2].HeaderCell.Value = "Apellido";
            this.clientsGridView.Columns[3].HeaderCell.Value = "Teléfono";
            this.clientsGridView.Columns[4].HeaderCell.Value = "Correo";
            this.clientsGridView.Columns[5].HeaderCell.Value = "Dirección";
            this.clientsGridView.Columns[6].Visible          = false;

            Connection.CloseConnection();
        }
Exemplo n.º 6
0
        //metodo cargar todo en la tabla
        public void loadData()
        {
            Connection.OpenConnection();
            transactionGridView.DataSource = Class.Transaction.showAllTransactions(Connection.myConnection);

            this.transactionGridView.Columns[0].HeaderCell.Value = "ID";
            this.transactionGridView.Columns[1].HeaderCell.Value = "Cuenta Origen";
            this.transactionGridView.Columns[2].HeaderCell.Value = "Cuenta Destino";
            this.transactionGridView.Columns[3].HeaderCell.Value = "Id Empleado";
            this.transactionGridView.Columns[4].HeaderCell.Value = "Fecha";
            this.transactionGridView.Columns[5].HeaderCell.Value = "Cantidad";
            this.transactionGridView.Columns[6].HeaderCell.Value = "Tipo de cuenta";
            this.transactionGridView.Columns[7].Visible          = false;

            Connection.CloseConnection();
        }
Exemplo n.º 7
0
        public void loadData()
        {
            Connection.OpenConnection();
            employesGridview.DataSource = Class.Employee.showAllEmployees(Connection.myConnection);

            this.employesGridview.Columns[0].HeaderCell.Value = "ID";
            this.employesGridview.Columns[1].HeaderCell.Value = "Nombre";
            this.employesGridview.Columns[2].HeaderCell.Value = "Apellido";
            this.employesGridview.Columns[3].HeaderCell.Value = "Teléfono";
            this.employesGridview.Columns[4].HeaderCell.Value = "Correo";
            this.employesGridview.Columns[5].HeaderCell.Value = "Direccion";
            this.employesGridview.Columns[6].HeaderCell.Value = "Contraseña";
            this.employesGridview.Columns[7].HeaderCell.Value = "Tipo Empleado";
            this.employesGridview.Columns[8].Visible          = false;

            Connection.CloseConnection();
        }
Exemplo n.º 8
0
        private void loadData()
        {
            Connection.OpenConnection();
            //se genera una lista con todos los clientes activos
            destinationDataGridView.DataSource = Class.Client.showAllClients(Connection.myConnection);

            //se establecen los nombres de cabecera para las columnas
            this.destinationDataGridView.Columns[0].HeaderCell.Value = "ID";
            this.destinationDataGridView.Columns[1].HeaderCell.Value = "Nombre";
            this.destinationDataGridView.Columns[2].HeaderCell.Value = "Apellido";
            this.destinationDataGridView.Columns[3].Visible          = false;
            this.destinationDataGridView.Columns[4].Visible          = false;
            this.destinationDataGridView.Columns[5].Visible          = false;
            this.destinationDataGridView.Columns[6].Visible          = false;

            Connection.CloseConnection();
        }
Exemplo n.º 9
0
        private void loadData()
        {
            Connection.OpenConnection();
            //se genera una lista con todos los clientes activos
            cancelDepositDataGridView.DataSource = Class.DepositWithoutAccount.showAllDeposits(Connection.myConnection);

            //se establecen los nombres de cabecera para las columnas
            this.cancelDepositDataGridView.Columns[0].HeaderCell.Value = "ID Deposito";
            this.cancelDepositDataGridView.Columns[1].HeaderCell.Value = "Id Empleado";
            this.cancelDepositDataGridView.Columns[2].HeaderCell.Value = "Cuenta Destino";
            this.cancelDepositDataGridView.Columns[3].HeaderCell.Value = "Fecha de deposito";
            this.cancelDepositDataGridView.Columns[4].HeaderCell.Value = "Cantidad";
            this.cancelDepositDataGridView.Columns[5].HeaderCell.Value = "Nombre";
            this.cancelDepositDataGridView.Columns[6].Visible          = false;

            Connection.CloseConnection();
        }
Exemplo n.º 10
0
        //metodo para cargar todos los datos a la tabla
        public void loadClientsData()
        {
            Connection.OpenConnection();
            //se genera una lista con todos los clientes activos
            clientsGridView.DataSource = Class.Client.showAllClients(Connection.myConnection);

            //se establecen los nombres de cabecera para las columnas
            this.clientsGridView.Columns[0].HeaderCell.Value = "ID";
            this.clientsGridView.Columns[1].HeaderCell.Value = "Nombre";
            this.clientsGridView.Columns[2].HeaderCell.Value = "Apellido";
            this.clientsGridView.Columns[3].HeaderCell.Value = "Teléfono";
            this.clientsGridView.Columns[4].HeaderCell.Value = "Correo";
            this.clientsGridView.Columns[5].HeaderCell.Value = "Dirección";
            this.clientsGridView.Columns[6].Visible          = false;

            Connection.CloseConnection();
        }
Exemplo n.º 11
0
        private void loadData()
        {
            Connection.OpenConnection();
            //se genera una lista con todos los clientes activos
            canceledDataGriedView.DataSource = Class.Transaction.showAllCanceled(Connection.myConnection);

            //se establecen los nombres de cabecera para las columnas
            this.canceledDataGriedView.Columns[0].HeaderCell.Value = "ID";
            this.canceledDataGriedView.Columns[1].HeaderCell.Value = "Cuenta origen";
            this.canceledDataGriedView.Columns[2].HeaderCell.Value = "Cuenta destino";
            this.canceledDataGriedView.Columns[3].HeaderCell.Value = "ID empleado";
            this.canceledDataGriedView.Columns[4].HeaderCell.Value = "Fecha";
            this.canceledDataGriedView.Columns[5].HeaderCell.Value = "Cantidad";
            this.canceledDataGriedView.Columns[6].HeaderCell.Value = "Tipo de cuenta";
            this.canceledDataGriedView.Columns[7].Visible          = false;

            Connection.CloseConnection();
        }
Exemplo n.º 12
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (niptextBox.Text == "" || balanceTextBox.Text == "" || maximumCreditTextBox.Text == "" ||
                accountTypeComboBox.SelectedItem == null)
            {
                MessageBox.Show("Favor de llenar todos los campos");
            }
            else
            {
                //abrir conexion de la db
                Connection.OpenConnection();

                //establecemos la fecha de corte
                DateTime today     = DateTime.Today;
                DateTime cutOffDay = today.AddDays(15);
                string   date      = today.ToString("yyyyMMdd");

                //establemos el tipo de cliente que sera
                int accountType;
                if (accountTypeComboBox.SelectedIndex == 0)
                {
                    //0 = Credito
                    accountType = 0;
                }
                else
                {
                    //1 = debito
                    accountType = 1;
                }

                Class.Account account = new Class.Account(1, Int32.Parse(idClient), niptextBox.Text, float.Parse(balanceTextBox.Text), float.Parse(maximumCreditTextBox.Text), date, accountType, true);

                if (Class.Account.addAccount(Connection.myConnection, account) == 1)
                {
                    //Cerrar conexion con db
                    Connection.CloseConnection();

                    //Mensaje de exito
                    MessageBox.Show("Cuenta registrada con exito");
                    this.Close();
                }
            }
        }
Exemplo n.º 13
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (firstNameTextBox.Text == "" || lastNameTextBox.Text == "" || phoneTextBox.Text == "" ||
                emailTextBox.Text == "" || addressTextBox.Text == "" || positionComboBox.SelectedItem == null)
            {
                MessageBox.Show("Favor de llenar todos los campos");
            }
            else
            {
                if (IsValidEmail(emailTextBox.Text) == true)
                {
                    Connection.OpenConnection();
                    int position;
                    if (positionComboBox.SelectedIndex == 0)
                    {
                        // 0 = gerente
                        position = 0;
                    }
                    else
                    {
                        //1 = empleado
                        position = 1;
                    }

                    Class.Employee newEmploye = new Class.Employee(1, firstNameTextBox.Text, lastNameTextBox.Text, phoneTextBox.Text, emailTextBox.Text, addressTextBox.Text, passwordTextBox.Text, position, true);
                    Class.Employee.addEmployee(Connection.myConnection, newEmploye);
                    Connection.CloseConnection();

                    MessageBox.Show("Empleado registrado\nExitosamente");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("El formato del correo no es correcto");
                }
            }
        }