private void button1_Click(object sender, RoutedEventArgs e) { string med = "NO"; if (yes.IsChecked == true) { med = "YES"; } if ((yes.IsChecked == false) && (no.IsChecked == false)) { MessageBox.Show("Please fill the required information !"); } else { for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId().ToString() == Enter_ID_Employee.employeeeid) { Containers.Employee_list[i].setMedicalReport(med); } } if (File.Exists("Employees.xml")) { File.Delete("Employees.xml"); } for (int i = 0; i < Containers.Employee_list.Count; i++) { Containers.write_Employee(Containers.Employee_list[i]); } if (Enter_ID_Employee.coaach == true) { for (int i = 0; i < Containers.Coach_list.Count; i++) { if (Containers.Coach_list[i].getId().ToString() == Enter_ID_Employee.employeeeid) { Containers.Coach_list[i].setMedicalReport(med); } } if (File.Exists("Coaches.xml")) { File.Delete("Coaches.xml"); } for (int i = 0; i < Containers.Coach_list.Count; i++) { Containers.write_coach(Containers.Coach_list[i]); } } MessageBox.Show("Changes Done"); } }
private void button1_Click(object sender, RoutedEventArgs e) { if (salary.Text == "") { MessageBox.Show("Please fill the required information !"); } else { for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId().ToString() == Enter_ID_Employee.employeeeid) { Containers.Employee_list[i].setSalary(float.Parse(salary.Text)); Containers.Employee_list[i].setsalarynot("YES"); } } if (File.Exists("Employees.xml")) { File.Delete("Employees.xml"); } for (int i = 0; i < Containers.Employee_list.Count; i++) { Containers.write_Employee(Containers.Employee_list[i]); } if (Enter_ID_Employee.coaach == true) { for (int i = 0; i < Containers.Coach_list.Count; i++) { if (Containers.Coach_list[i].getId().ToString() == Enter_ID_Employee.employeeeid) { Containers.Coach_list[i].setSalary(float.Parse(salary.Text)); } } if (File.Exists("Coaches.xml")) { File.Delete("Coaches.xml"); } for (int i = 0; i < Containers.Coach_list.Count; i++) { Containers.write_coach(Containers.Coach_list[i]); } } MessageBox.Show("Changes Done"); } }
private void delete_Click(object sender, RoutedEventArgs e) { if (id.Text == "") { MessageBox.Show("Please Enter ID"); } else { employeeeid = id.Text; bool noo = false; for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId() == id.Text) { if (Containers.Employee_list[i].GetDepartment() == "HR" && employeelogin.hrid == true || (Containers.Employee_list[i].GetDepartment() == "HR" && Edit_EmployeePassword.ggg == true)) { MessageBox.Show("You are not allowed to edit or delete HR Employee"); noo = true; break; } else if (Containers.Employee_list[i].GetDepartment() == "Coach") { coaach = true; } } } if (noo == false) { bool find = false; for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId() == id.Text) { Containers.Employee_list.Remove(Containers.Employee_list[i]); find = true; } } if (find == false) { MessageBox.Show("Wrong ID"); } else { if (File.Exists("Employees.xml")) { File.Delete("Employees.xml"); } for (int i = 0; i < Containers.Employee_list.Count; i++) { Containers.write_Employee(Containers.Employee_list[i]); } MessageBox.Show("Employee Successfuly Deleted"); if (coaach == true) { for (int i = 0; i < Containers.Coach_list.Count; i++) { if (Containers.Coach_list[i].getId() == id.Text) { Containers.Coach_list.Remove(Containers.Coach_list[i]); } } if (File.Exists("Coaches.xml")) { File.Delete("Coaches.xml"); } for (int i = 0; i < Containers.Coach_list.Count; i++) { Containers.write_coach(Containers.Coach_list[i]); } MessageBox.Show("Coach Successfuly Deleted"); } } } } }
private void button_Click(object sender, RoutedEventArgs e) { if (typee.Text == "" || result.Text == "" || name1.Text == "" || places.Text == "") { MessageBox.Show("Please fill the required information !"); } else { bool ch_found = false; for (int i = 0; i < Containers.championship_list.Count; i++) { if (Containers.championship_list[i].getName() == name1.Text && Containers.championship_list[i].GetPlace() == places.Text && Containers.championship_list[i].Gettype() == typee.Text) { ch_found = true; } } if (ch_found == false) { MessageBox.Show("Please Enter a Valid ChampionShip"); } else { string coachname = ""; int x = int.Parse(result.Text); for (int i = 0; i < Containers.Player_list.Count; i++) { if (Containers.Player_list[i].getId().ToString() == Enter_ID.playerid) { coachname = Containers.Player_list[i].get_CoachName(); } } for (int i = 0; i < Containers.Coach_list.Count; i++) { if (Containers.Coach_list[i].getName() == coachname) { Containers.Coach_list[i].setResult(Containers.Coach_list[i].getResult() + x); break; } } if (File.Exists("Coaches.xml")) { File.Delete("Coaches.xml"); } for (int i = 0; i < Containers.Coach_list.Count; i++) { Containers.write_coach(Containers.Coach_list[i]); } if (!File.Exists("Results.xml")) { XmlTextWriter document = new XmlTextWriter("Results.xml", Encoding.UTF8); document.Formatting = Formatting.Indented; document.WriteStartDocument(); document.WriteStartElement("Results"); document.WriteStartElement("Result"); document.WriteStartElement("Player_ID"); document.WriteString(Enter_ID.playerid); document.WriteEndElement(); document.WriteStartElement("Championship_Type"); document.WriteString(typee.Text); document.WriteEndElement(); document.WriteStartElement("Championship_Place"); document.WriteString(places.Text); document.WriteEndElement(); document.WriteStartElement("Results"); document.WriteString(result.Text); document.WriteEndElement(); document.WriteStartElement("Name"); document.WriteString(name1.Text); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndDocument(); document.Close(); MessageBox.Show("Player Results Successfuly added."); } else { XmlDocument doc = new XmlDocument(); doc.Load("Results.xml"); XmlNode resultt = doc.CreateElement("Result"); XmlNode id = doc.CreateElement("Player_ID"); id.InnerText = Enter_ID.playerid; resultt.AppendChild(id); XmlNode type = doc.CreateElement("Championship_Type"); type.InnerText = typee.Text; resultt.AppendChild(type); XmlNode placee = doc.CreateElement("Championship_Place"); placee.InnerText = places.Text; resultt.AppendChild(placee); XmlNode res = doc.CreateElement("Results"); res.InnerText = result.Text; resultt.AppendChild(res); XmlNode names = doc.CreateElement("Name"); names.InnerText = name1.Text; resultt.AppendChild(names); doc.DocumentElement.AppendChild(resultt); doc.Save("Results.xml"); MessageBox.Show("Player Result Successfuly added."); } } } }
private void button_Click(object sender, RoutedEventArgs e) { if (textBox1.Text == "" || mobile.Text == "") { MessageBox.Show("Please fill the required information !"); } else if (mobile.Text.Length != 11) { MessageBox.Show("Please Enter Valid Mobile Number!"); } else { bool mobilee = false; for (int i = 0; i < Containers.Employee_list.Count(); i++) { if (Containers.Employee_list[i].getId().ToString() == Enter_ID_Employee.employeeeid) { if (Containers.Employee_list[i].getmobile() == textBox1.Text) { mobilee = true; } } } bool mobiles = false; for (int i = 0; i < Containers.Employee_list.Count(); i++) { if (Containers.Employee_list[i].getmobile() == mobile.Text) { mobiles = true; } } for (int i = 0; i < Containers.Player_list.Count(); i++) { if (Containers.Player_list[i].getmobile() == mobile.Text) { mobiles = true; } } if (mobiles == true) { MessageBox.Show("Please Re-enter Mobile Number !"); } else if (mobilee == false) { MessageBox.Show("Wrong Mobile Number"); } else { for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId().ToString() == Enter_ID_Employee.employeeeid) { Containers.Employee_list[i].setmobile(mobile.Text); break; } } if (File.Exists("Employees.xml")) { File.Delete("Employees.xml"); } for (int i = 0; i < Containers.Employee_list.Count; i++) { Containers.write_Employee(Containers.Employee_list[i]); } if (Enter_ID_Employee.coaach == true) { for (int i = 0; i < Containers.Coach_list.Count; i++) { if (Containers.Coach_list[i].getId().ToString() == Enter_ID_Employee.employeeeid) { Containers.Coach_list[i].setmobile(mobile.Text); break; } } if (File.Exists("Coaches.xml")) { File.Delete("Coaches.xml"); } for (int i = 0; i < Containers.Coach_list.Count; i++) { Containers.write_coach(Containers.Coach_list[i]); } } MessageBox.Show("Changes Done"); } } }