private void Report_Load(object sender, EventArgs e)
        {
            Database11DataSetTableAdapters.TeacherTableAdapter tr = new Database11DataSetTableAdapters.TeacherTableAdapter();
            Database11DataSet.TeacherDataTable dt1 = tr.GetData();//tr=teacher
            dataGridView1.DataSource = dt1;

            Database11DataSetTableAdapters.ProfileTableAdapter pr = new Database11DataSetTableAdapters.ProfileTableAdapter();
            Database11DataSet.ProfileDataTable dt2 = pr.GetDataBy();//pr=profile
            dataGridView2.DataSource = dt2;

            label6.Text  = "";
            label8.Text  = "";
            label9.Text  = "";
            label10.Text = "";
            label11.Text = "";
        }
Example #2
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtUsername.Text))
     {
         MessageBox.Show("Please enter your username.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtUsername.Focus();
         return;
     }
     try
     {
         //Get data from user table
         Database11DataSetTableAdapters.AdminTableAdapter admin = new Database11DataSetTableAdapters.AdminTableAdapter();
         Database11DataSet.AdminDataTable dt = admin.GetDataByUsernamePassword(txtUsername.Text, txtPassword.Text);
         Database11DataSetTableAdapters.TeacherTableAdapter teacher = new Database11DataSetTableAdapters.TeacherTableAdapter();
         Database11DataSet.TeacherDataTable dt1 = teacher.GetDataByUsernamePasswordTeacher(txtUsername.Text, txtPassword.Text);
         Database11DataSetTableAdapters.ProfileTableAdapter student = new Database11DataSetTableAdapters.ProfileTableAdapter();
         Database11DataSet.ProfileDataTable dt2 = student.GetDataByUsernamePasswordProfile(txtUsername.Text, txtPassword.Text);
         //Check row > 0
         if (dt.Rows.Count > 0)
         {
             MessageBox.Show("You have been successfully logged in.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //Process your login here
             this.Hide();
             Admin ss = new Admin();
             ss.ShowDialog();
             this.Close();
         }
         else if (dt1.Rows.Count > 0)
         {
             MessageBox.Show("You have been successfully logged in.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //Process your login here
         }
         else if (dt2.Rows.Count > 0)
         {
             MessageBox.Show("You have been successfully logged in.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //Process your login here
         }
         else
         {
             MessageBox.Show("Your username or password is incorrect.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }