Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            MainAppWindow maw = new MainAppWindow();

            maw.Show();
            this.Close();
        }
Example #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "" || textBox2.Text == "")
     {
         MessageBox.Show("Enter correct details");
         textBox1.Clear();
         textBox2.Clear();
     }
     else
     {
         try {
             using (SqlConnection conn = new SqlConnection("Data Source=HAIER-PC\\SQLEXPRESS;Initial Catalog=TodoListDatabase;Integrated Security=True"))
             {
                 conn.Open();
                 string         cmd = "SELECT STUDENT_ID FROM USERS WHERE STUDENT_ID = '" + Convert.ToInt32(textBox1.Text) + "' AND PASSWORD = '******'";
                 SqlDataAdapter da  = new SqlDataAdapter(cmd, conn);
                 DataSet        ds  = new DataSet();
                 da.Fill(ds);
                 DataTable dt = ds.Tables[0];
                 conn.Close();
                 if (dt.Rows.Count >= 1)
                 {
                     settext = Convert.ToInt32(textBox1.Text);
                     MainAppWindow maw = new MainAppWindow();
                     maw.Show();
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Wrong username/pass combination");
                     textBox1.Clear();
                     textBox2.Clear();
                 }
             }
         }
         catch
         {
             MessageBox.Show("Invalid username/password");
         }
     }
 }
Example #3
0
 private void add_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "")
     {
         using (SqlConnection conn = new SqlConnection("Data Source=HAIER-PC\\SQLEXPRESS;Initial Catalog=TodoListDatabase;Integrated Security=True"))
         {
             conn.Open();
             SqlCommand add = conn.CreateCommand();
             add.CommandType = CommandType.Text;
             add.CommandText = "INSERT INTO TASKS (Student_ID, Task_Name, Deadline) VALUES ('" + Form1.settext + "', '" + textBox1.Text + "', '" + dateTimePicker1.Value + "')";
             add.ExecuteNonQuery();
             conn.Close();
             MessageBox.Show(string.Format("{0} has been added", textBox1.Text));
             MainAppWindow maw = new MainAppWindow();
             maw.Show();
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Enter correct values");
     }
 }