private void button_Verify_Update_Click(object sender, EventArgs e)//UPDATE Password Button (ADMIN SECTION) { if (textBox_New_Pass.Text != "") { try { LinqLoginDataContext lq = new LinqLoginDataContext(strCon); var x = from a in lq.Logins where a.Password == textBox_Old_Pass.Text select a; x.First().Password = textBox_New_Pass.Text; lq.SubmitChanges(); dataGrid_Admin_List.DataSource = x.ToList(); MessageBox.Show("Success!"); } catch { MessageBox.Show("Wrong Password! Try again."); } } else { MessageBox.Show("Please insert a new password"); } }
private void button4_Click(object sender, EventArgs e)//ADD Admin { if (textBox2.Text != "" && textBox3.Text != "") { if (textBox3.Text.Length >= 4) { LinqLoginDataContext lq = new LinqLoginDataContext(strCon); Login lg = new Login { Username = textBox2.Text, Password = textBox3.Text }; MessageBox.Show("Admin added successfully!"); lq.Logins.InsertOnSubmit(lg); lq.SubmitChanges(); // UpdateGridView(); } else { MessageBox.Show("Password must have minimum 4 characters!"); } } else { MessageBox.Show("(Error!) Input username & password!"); } }
private void button_Verify_Update_Click(object sender, EventArgs e)//UPDATE Password Button (ADMIN SECTION) { if (textBox_New_Pass.Text != "") { try { LinqLoginDataContext lq = new LinqLoginDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30"); var x = from a in lq.Logins where a.Password == textBox_Old_Pass.Text select a; x.First().Password = textBox_New_Pass.Text; lq.SubmitChanges(); dataGrid_Admin_List.DataSource = x.ToList(); MessageBox.Show("Success!"); } catch { MessageBox.Show("Wrong Password! Try again."); } } else { MessageBox.Show("Please insert a new password"); } }
private void button4_Click(object sender, EventArgs e)//ADD Admin { if (textBox2.Text != "" && textBox3.Text != "") { if (textBox3.Text.Length >= 4) { LinqLoginDataContext lq = new LinqLoginDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30"); Login lg = new Login { Username = textBox2.Text, Password = textBox3.Text }; MessageBox.Show("Admin added successfully!"); lq.Logins.InsertOnSubmit(lg); lq.SubmitChanges(); // UpdateGridView(); } else { MessageBox.Show("Password must have minimum 4 characters!"); } } else { MessageBox.Show("(Error!) Input username & password!"); } }
private void button5_Click(object sender, EventArgs e)//REMOVE Admin { LinqLoginDataContext lq = new LinqLoginDataContext(strCon); if (textBox4.Text != "") { var x = from a in lq.Logins where a.Username.Equals(textBox4.Text) select a; //Lamda Expression foreach (Login l in x) { lq.Logins.DeleteOnSubmit(l); } lq.SubmitChanges(); dataGrid_Admin_List.DataSource = lq; } else { MessageBox.Show("Input an Admin name!"); } }
private void button5_Click(object sender, EventArgs e)//REMOVE Admin { LinqLoginDataContext lq = new LinqLoginDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30"); if (textBox4.Text != "") { var x = from a in lq.Logins where a.Username.Equals(textBox4.Text) select a; //Lamda Expression foreach (Login l in x) { lq.Logins.DeleteOnSubmit(l); } lq.SubmitChanges(); dataGrid_Admin_List.DataSource = lq; } else { MessageBox.Show("Input an Admin name!"); } }