Example #1
0
        private void accounts_Click(object sender, EventArgs e)
        {
            this.IsMdiContainer = true;
            form_accounts form_accounts = new form_accounts(username);

            form_accounts.MdiParent = this;
            form_accounts.Show();
        }
Example #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (action == "add")
                {
                    validate();
                    if (error == 0)
                    {
                        Account.executeSQL("INSERT INTO tblaccounts VALUES ('" + txtb_username.Text + "' , '" + txtb_password.Text +
                                           "' , '" + cmb_usertype.Text + "' , '" + cmb_branch.Text + "' , '" + cmb_dept.Text + "' , 'active')");
                        if (Account.rowAffected > 0)
                        {
                            MessageBox.Show("New Account Added", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Account.executeSQL("INSERT INTO tbllogs VALUES ('" + DateTime.Now.ToString() +
                                               "' , 'added new user with username of " + txtb_username.Text + "' , 'Account Management' , '" +
                                               username + "')");
                            this.Hide();

                            //refresh datagrid
                            form_accounts add = (form_accounts)Application.OpenForms["form_accounts"];
                            add.refresh();
                        }
                    }
                }

                else if (action == "update")
                {
                    Account.executeSQL(" update tblaccounts set user_type = '" + cmb_usertype.Text + "' , branch = '" + cmb_branch.Text + "' , department = '" + cmb_dept.Text + "' where username = '******' ");
                    if (Account.rowAffected > 0)
                    {
                        MessageBox.Show(" Account updated", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Account.executeSQL("INSERT INTO tbllogs VALUES ('" + DateTime.Now.ToString() +
                                           "' , 'updated an account with username of " + txtb_username.Text + "' , 'Account Management' , '" +
                                           username + "')");
                        this.Hide();

                        //refresh datagrid
                        form_accounts update = (form_accounts)Application.OpenForms["form_accounts"];
                        update.refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }