Beispiel #1
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            frmAdmin myAdmin = new frmAdmin();

            this.Hide();
            myAdmin.FormClosed += (s, args) => this.Close();
            myAdmin.Show();
            myAdmin.Focus();
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text == "")
            {
                MessageBox.Show("Please enter your password", "STOKVEL MANAGEMENT SYSTEM", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtPassword.Focus();
            }
            else
            {
                AdminCode = "Admin@" + (txtLast.Text).ToUpper() + (txtID.Text).Substring(0, 2);

                try
                {
                    myDb.Open();
                    OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Administrator", myDb);
                    OleDbCommand     sql     = new OleDbCommand(@"insert into Administrator([AdminID],[First Name],[Last Name],[ID Number],[Gender],[Password]) values('" + AdminCode + "','" + txtFirst.Text + "','" + txtLast.Text + "','" + txtID.Text + "','" + cmbBxGender.SelectedItem + "','" + txtPassword.Text + "')", myDb);

                    adapter.InsertCommand = sql;

                    sql.ExecuteNonQuery();

                    MessageBox.Show(" Inserted Record.", "STOKVEL MANAGEMENT SYSTEM", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    myDb.Close();
                }

                MessageBox.Show("Use  " + AdminCode + " as your username");

                frmAdmin myAdmin = new frmAdmin();
                this.Hide();
                myAdmin.FormClosed += (s, args) => this.Close();
                myAdmin.Show();
                myAdmin.Focus();
            }
        }