Пример #1
0
        private void modifyButton_Click(object sender, EventArgs e)
        {
            if (nipTextBox.Text == "" || balancetextBox.Text == "" || maximumCreditTextBox.Text == "")
            {
                MessageBox.Show("Favor de llenar todos los campos");
            }
            else
            {
                int type;
                if (accountTypeComboBox.SelectedIndex == 0)
                {
                    // 0 = credito
                    type = 0;
                }
                else
                {
                    // 1 = debito
                    type = 1;
                }

                string cutOffDay = cutOffDayDateTimePicker.Text;

                Connection.OpenConnection();
                Class.Account account = new Class.Account(Convert.ToInt32(idAccountTextBox.Text), Convert.ToInt32(idClientTextBox.Text), nipTextBox.Text, float.Parse(balancetextBox.Text), float.Parse(maximumCreditTextBox.Text), cutOffDay, type, true);
                Class.Account.modifyAccount(Connection.myConnection, account);
                Connection.CloseConnection();

                MessageBox.Show("Modificado exitosamente");
                this.Close();
            }
        }
Пример #2
0
        private bool haveBalance(int idAccount, float money)
        {
            bool answer = false;

            try
            {
                Connection.OpenConnection();
                MySqlCommand    command = new MySqlCommand(String.Format("SELECT * from Account WHERE idAccount = '{0}' AND Active = true", idAccount), Connection.myConnection);
                MySqlDataReader reader  = command.ExecuteReader();

                if (reader.Read())
                {
                    Class.Account account = new Class.Account(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetFloat(3), reader.GetFloat(4), reader.GetString(5), reader.GetInt32(6), reader.GetBoolean(7));
                    Connection.CloseConnection();

                    if (account.Balance < money)
                    {
                        answer = true;
                    }
                    else
                    {
                        answer = false;
                    }
                }
            }
            catch (Exception)
            {
                //exception
            }

            return(answer);
        }
Пример #3
0
 public DuplicateUserData(Class.Account parentaccount, List <Class.Account> childaccount)
 {
     InitializeComponent();
     ParentAccount    = parentaccount;
     ChildAccount     = childaccount;
     ParentAccountDir = Path.Combine(Globals.Config.steamPath, $"userdata\\{parentaccount.ResolveSteamID3()}");
 }
Пример #4
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();
        }
Пример #5
0
        public ClickLogin(ref Class.Account _account)
        {
            account = _account;
            InitializeComponent();
            windowinfo.cbSize = (uint)Marshal.SizeOf(windowinfo);

#if !DEBUG
            lbldbg.Visible = false;
            this.Height    = 96;
#endif
        }
Пример #6
0
        private void BtnApply_Click(object sender, EventArgs e)
        {
            tbURL_Sanitize(); // Sanitize the url

            // Validate user input
            if (!string.IsNullOrWhiteSpace(tbURL.Text) ||
                (!string.IsNullOrWhiteSpace(tbUser.Text) && !string.IsNullOrWhiteSpace(tbPass.Text)))
            {
                // Validates the steam URL
                if (!string.IsNullOrWhiteSpace(tbURL.Text) && !tbURL.Text.StartsWith("id/") && !tbURL.Text.StartsWith("profiles/"))
                {
                    MessageBox.Show("Invalid Steam URL!", "Account", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                // Edit account
                if (mode)
                {
                    account.LVI.SubItems[1].Text = account.SteamURL = tbURL.Text;
                    account.LVI.SubItems[3].Text = account.Username = tbUser.Text;
                    account.Password             = tbPass.Text;
                    account.LVI.SubItems[6].Text = account.Note = tbNote.Text;

                    if (Globals.hFormMain.SelectedAccount == account)
                    {
                        Globals.hFormMain.tbNote.Text = account.Note; // This might trigger the event rendering the upper assignment useless but, eh.
                    }
                }

                // Add account
                else
                {
                    string uniqueId = Utils.Account.MakeUniqueKey();

                    // Create the new account
                    Class.Account _account = new Class.Account(DateTime.MinValue, uniqueId, tbURL.Text, "", tbUser.Text, tbPass.Text, tbNote.Text, false);

                    // Add it
                    Globals.CurrentProfile.Profiles.Add(uniqueId, _account);
                    Utils.Account.AddToTable(ref lvData, uniqueId, ref _account);

                    // Finish
                    cache_addAnotherFlag = true;
                }

                this.Close();
            }
            else
            {
                MessageBox.Show("You must atleast provide a steam url (that begins with either \"id/\" or \"profile/\") or a username and password to make a valid entry!", "Add account", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #7
0
        public static void AddToTable(ref ListView _lv, string _uniqueID, ref Class.Account _account)
        {
            _account.LVI = (new ListViewItem(_uniqueID));
            _account.LVI.SubItems.AddRange(new String[] { _account.SteamURL, _account.Name, _account.Username, _account.Banned.ToString(), "", _account.Note, "" });
            _lv.Items.Add(_account.LVI);

            if (_uniqueID == Globals.CurrentProfile.LastAccountLoggedIn)
            {
                Globals.LastAccountLogin = _account;
                _account.LVI.BackColor   = System.Drawing.Color.FromArgb(255, 20, 20, 20);
            }
        }
Пример #8
0
        private void BtnImport_Click(object sender, EventArgs e)
        {
            Class.Account _acc;
            foreach (ListViewItem _lvi in lvImports.CheckedItems)
            {
                string uniqueId = Utils.Account.MakeUniqueKey();
                _acc = new Class.Account(DateTime.MinValue, uniqueId, _lvi.SubItems[0].Text, "", _lvi.SubItems[1].Text, _lvi.SubItems[2].Text, "", false);
                Globals.CurrentProfile.Profiles.Add(uniqueId, _acc);
                Utils.Account.AddToTable(ref lvRef, uniqueId, ref _acc);
            }

            this.Close();
        }
Пример #9
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();
                }
            }
        }
Пример #10
0
 public AccountInfo(ref Class.Account _account)
 {
     account = _account;
     mode    = true;
     InitializeComponent();
 }
Пример #11
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            if (origenDataGridView.Rows.Count == 0 || destinationGridView.Rows.Count == 0)
            {
                MessageBox.Show("Las tablas estan vacias");
            }
            else if (origenDataGridView.CurrentRow.Cells[0].Value.ToString() == destinationGridView.CurrentRow.Cells[0].Value.ToString())
            {
                MessageBox.Show("No se puede transferir a la misma cuenta");
            }
            else if (quantityTextBox.Text == "")
            {
                MessageBox.Show("Favor de llenar todos los campos");
            }
            else
            {
                //Abrimos conexion con la db
                Connection.OpenConnection();
                //tomamos el id del cliente origen
                string idOrigenClient = origenDataGridView.CurrentRow.Cells[0].Value.ToString();
                //obtenemos el id de la cuenta
                int idOrigen = Class.Account.searchIdAccount(Connection.myConnection, idOrigenClient);
                //cerramos la conexion a la db
                Connection.CloseConnection();


                //abrimos conexion a db
                Connection.OpenConnection();
                //tomamos el id del cliente destino
                string idDestinationClient = destinationGridView.CurrentRow.Cells[0].Value.ToString();
                //obtenemos el id de la cuenta
                int idDestination = Class.Account.searchIdAccount(Connection.myConnection, idDestinationClient);
                //ceramos conexion a db
                Connection.CloseConnection();

                //establecemos el tipo de cuenta
                int type;
                if (accountTypeComboBox.SelectedIndex == 0)
                {
                    // 0 = Credito
                    type = 0;
                }
                else
                {
                    //1 = Debito
                    type = 1;
                }

                //abrimos conexion
                Connection.OpenConnection();
                //realizamos el query para la cuenta
                MySqlCommand    command = new MySqlCommand(String.Format("SELECT * from Account WHERE idAccount = '{0}' AND Active  = true", idOrigen), Connection.myConnection);
                MySqlDataReader reader  = command.ExecuteReader();

                //si la cuenta existe entramos
                if (reader.Read())
                {
                    //se genera un objeto de tipo cuenta con todos los datos de la cuenta origen
                    Class.Account valAccount = new Class.Account(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetFloat(3), reader.GetFloat(4), reader.GetString(5), reader.GetInt32(6), reader.GetBoolean(7));
                    //se cierra la conexion
                    Connection.CloseConnection();

                    //validacion si el saldo de la cuenta es menor a la cantidad se genera un mensaje de error
                    if (valAccount.Balance < Convert.ToInt32(quantityTextBox.Text))
                    {
                        MessageBox.Show("La cuenta origen no tiene el saldo suficiente");
                    }
                    else
                    {
                        //abrimos conexion a db
                        Connection.OpenConnection();
                        //establecemos la fecha de la transaccion
                        DateTime today = DateTime.Today;
                        string   date  = today.ToString("yyyyMMdd");

                        //creamos el objeto de tipo transaccion
                        Class.Transaction transaction = new Class.Transaction(1, idOrigen, idDestination, idEployee, date, float.Parse(quantityTextBox.Text), type, false);

                        //intentamos ingresar a la db
                        if (Class.Transaction.addTransaction(Connection.myConnection, transaction) == 1)
                        {
                            //cerramos conexion
                            Connection.CloseConnection();

                            MessageBox.Show("Se ha transferido el dinero");
                            this.Close();
                        }
                    }
                }
            }
        }
Пример #12
0
        // Login the account
        public bool Login(LOGINMETHOD mode = LOGINMETHOD.NORMAL)
        {
            if (string.IsNullOrWhiteSpace(this.Username) || string.IsNullOrWhiteSpace(this.Password))
            {
                MessageBox.Show("This account doesn't contain any credentials to login to", "Login Account", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (Globals.IsLoggingIn)
            {
                MessageBox.Show("The application is already actively logging in an account!", "Login Account", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            // Make sure steam is closed. Only check if logging in with normal or force
            if (mode < LOGINMETHOD.NORMAL_NO_CHECK)
            {
                Process[] _temp_proc_list;
                while ((_temp_proc_list = Process.GetProcessesByName("Steam")).Count() > 0)
                {
                    if (mode == LOGINMETHOD.FORCE || MessageBox.Show("OWL has detected that the Steam client is still running. Would you like to close it forcibly? This is not recommended since it can cause instability. Only choose this option if you know what you're doing.", "Login Account", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        foreach (Process steam in _temp_proc_list)
                        {
                            steam.Kill();
                        }
                    }
                    else
                    {
                        return(false);
                    }

                    Thread.Sleep(800); // lazy
                }
            }

            Globals.IsLoggingIn = true;
            Globals.hFormMain.FormMain_UpdateTitle();

            if (Globals.LastAccountLogin != null)
            {
                Globals.LastAccountLogin.LVI.BackColor = System.Drawing.Color.FromArgb(255, 42, 42, 42);
            }

            Globals.LastAccountLogin = this;
            this.LVI.BackColor       = System.Drawing.Color.FromArgb(255, 20, 20, 20);

            Globals.CurrentProfile.LastAccountLoggedIn = this.LVI.SubItems[0].Text;

            new Thread(new ThreadStart(() =>
            {
                if (mode == LOGINMETHOD.CLICK_CREDENTIALS)
                {
                    Class.Account _acc = this;
                    new Forms.ClickLogin(ref _acc).ShowDialog();
                }
                else
                {
                    Process.Start(Globals.Config.steamPath + "/Steam.exe", $"-login \"{this.Username}\" \"{this.Password}\" {Globals.Config.steamParam}");
                }

                Globals.hFormMain.Invoke(new Action(() =>
                {
                    Globals.IsLoggingIn = false;
                    Globals.hFormMain.FormMain_UpdateTitle();
                }));
            }
                                       )).Start();

            return(true);
        }