private void btnBack_Click(object sender, EventArgs e)
        {
            frmTeacherMain frm = new frmTeacherMain(TeacherID);

            frm.Show();
            this.Hide();
        }
예제 #2
0
        private void btnTeacherLogin_Click(object sender, EventArgs e)
        {
            string         pass    = textBoxTeacherPass.Text;
            int            len     = pass.Length;
            SqlConnection  con     = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\MyDB\MyDB.mdf;Integrated Security=True;Connect Timeout=30");
            string         query   = "Select * from Teacher where ID='" + textBoxTeacherID.Text.Trim() + "' and Password ='******'";
            SqlDataAdapter adapter = new SqlDataAdapter(query, con);
            DataTable      table   = new DataTable();

            adapter.Fill(table);

            if (textBoxTeacherID.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Teacher ID is Required  ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxTeacherID.Clear();
                textBoxTeacherID.Focus();
            }

            else if (textBoxTeacherPass.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Password is Required  ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxTeacherPass.Clear();
                textBoxTeacherPass.Focus();
            }
            else if (len < 8)
            {
                MessageBox.Show("Password Must Be 8 Digit");
            }
            else if (table.Rows.Count == 1)
            {
                TeacherID = textBoxTeacherID.Text;
                frmTeacherMain frm = new frmTeacherMain(TeacherID);
                this.Hide();
                frm.Show();
            }

            else
            {
                MessageBox.Show("Teacher ID or Password is Invalid  ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }