private void Updatebtn_Click(object sender, RoutedEventArgs e) { var update = MessageBox.Show("Would you like to update the data??", "Data Update", MessageBoxButton.YesNo, MessageBoxImage.Question); if (update == MessageBoxResult.Yes) { customer cus = new customer(CustList.SelectedIndex, Name_tb.Text, Address_tb.Text, Email_tb.Text, Phone_tb.Text); foreach (customer csitem in cq) { if (cus.Id == csitem.Id) { csitem.Name = Name_tb.Text; csitem.Address = Address_tb.Text; csitem.Email = Email_tb.Text; csitem.Phone = Phone_tb.Text; } } var upd = from up in cq select up.Name; CustList.DataContext = upd; Name_tb.Clear(); Address_tb.Clear(); Email_tb.Clear(); Phone_tb.Clear(); MessageBox.Show("Details have been successfully Updated!!!", "Data Updated", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void Delete_Click(object sender, RoutedEventArgs e) { var delete = MessageBox.Show("Would you like to update the data??", "Data Update", MessageBoxButton.YesNo, MessageBoxImage.Question); if (delete == MessageBoxResult.Yes) { while (true) { customer tempc = cq.Dequeue(); if (tempc.Id == CustList.SelectedIndex) { break; } cq.Enqueue(tempc); } int i = 0; foreach (customer item in cq) { item.Id = i; i++; } var del = from cust in cq select cust.Name; CustList.DataContext = del; Name_tb.Clear(); Address_tb.Clear(); Email_tb.Clear(); Phone_tb.Clear(); MessageBox.Show("Information is successfully deleted!!!", "Information Deleted", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void Login_Button_Click(object sender, EventArgs e) { if (Email_tb.Text.Equals(string.Empty)) { MessageBox.Show(" Email Is Required", "warnning", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Password_tb.Text.Equals(string.Empty)) { MessageBox.Show("Password Is Required", "warnning", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { using (IDbConnection con = new SqlConnection(SQLConnection.getConnection())) { con.Open(); var user = con.Query <StaffRegistration>("Select * from dbo.StaffRegistration Where Email = @Email", new { @Email = Email_tb.Text }).FirstOrDefault(); if (user != null) { if (user.Password.Equals(Password_tb.Text)) { Session.FullName = user.FirstName + " " + user.MiddleName + " " + user.LastName; Session.Email = user.Email; Session.Faculty = user.Faculty; Session.PhoneNo = user.PhoneNo; Session.LoginDateTime = DateTime.Now; this.Hide(); MDIParent1 mDIParent1 = new MDIParent1(); mDIParent1.ShowDialog(); } else { MessageBox.Show("Invalid Email or Password.", "warnning", MessageBoxButtons.OK, MessageBoxIcon.Information); Email_tb.Focus(); } } else { MessageBox.Show("Invalid Email or Password.", "warnning", MessageBoxButtons.OK, MessageBoxIcon.Information); Email_tb.Focus(); } } } }
private void Addbtn_Click(object sender, RoutedEventArgs e) { if (Name_tb.Text == "" || Address_tb.Text == "" || Email_tb.Text == "" || Phone_tb.Text == "") { MessageBox.Show("All fields are required to add new customer", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { cq.Enqueue(new customer(cq.Count, Name_tb.Text, Address_tb.Text, Email_tb.Text, Phone_tb.Text)); var ins = from cu in cq select cu.Name; CustList.DataContext = ins; Name_tb.Clear(); Address_tb.Clear(); Email_tb.Clear(); Phone_tb.Clear(); MessageBox.Show("New infromation is successfully added!!!", "New Information Added", MessageBoxButton.OK, MessageBoxImage.Information); } }