private void button1_Click(object sender, RoutedEventArgs e) { bool mobiles = false; for (int i = 0; i < Containers.Player_list.Count(); i++) { if (Containers.Player_list[i].getmobile() == mobilee.Text) { mobiles = true; } } if (textBox1.Text == "" || mobilee.Text == "") { MessageBox.Show("Please fill the required information !"); } else if (mobiles == true) { MessageBox.Show("Mobile number is already registered !"); } else if (textBox1.Text == mobilee.Text) { MessageBox.Show("Please enter a diffrent Mobile Number!"); textBox1.Clear(); mobilee.Clear(); } else { for (int i = 0; i < Containers.Player_list.Count; i++) { if (Containers.Player_list[i].getId().ToString() == Enter_ID.playerid) { Containers.Player_list[i].setmobile(mobilee.Text); } } if (File.Exists("Players.xml")) { File.Delete("Players.xml"); } for (int i = 0; i < Containers.Player_list.Count; i++) { Containers.write_Player(Containers.Player_list[i]); } MessageBox.Show("Changes Done"); this.Hide(); } }
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"); } }
public ChartDemo() { // Demo Data if (File.Exists("Employees.xml")) { Containers.Read_Employees(); } Dictionary <string, float> departmentSalaries = new Dictionary <string, float>(); Dictionary <string, int> departmentFrequency = new Dictionary <string, int>(); // Initializing Each Department Accumulative Salary foreach (Employee employee in Containers.Employee_list) { if (departmentSalaries.ContainsKey(employee.GetDepartment())) { departmentSalaries[employee.GetDepartment()] += employee.getSalary(); departmentFrequency[employee.GetDepartment()]++; } else { departmentSalaries.Add(employee.GetDepartment(), employee.getSalary()); departmentFrequency.Add(employee.GetDepartment(), 1); } } // Calculating the Median of the Salaries List <string> Keys = new List <string>(departmentSalaries.Keys); foreach (string department in Keys) { departmentSalaries[department] /= departmentFrequency[department]; } Data = new SeriesCollection { new LineSeries { Values = new ChartValues <float>(departmentSalaries.Values) } }; Labels = new List <string>(departmentSalaries.Keys); InitializeComponent(); MainChart.Series = Data; HorizontalAxis.Labels = Labels; }
public MainWindow() { InitializeComponent(); Containers.Read_Players(); Containers.Read_Championships(); Containers.Read_Employees(); Containers.Read_Clubs(); Containers.Read_Teams(); AGE a = new SFS.AGE(); a.Show(); mainqueryform f = new mainqueryform(); f.Show(); Options o = new Options(); o.Show(); }
public MainWindow() { InitializeComponent(); if (File.Exists("Championships.xml")) { Containers.Read_Championships(); } if (File.Exists("Players.xml")) { Containers.Read_Players(); } if (File.Exists("Employees.xml")) { Containers.Read_Employees(); } if (File.Exists("Clubs.xml")) { Containers.Read_Clubs(); } if (File.Exists("Teams.xml")) { Containers.Read_Teams(); } if (File.Exists("Coaches.xml")) { Containers.Read_Coach(); } if (File.Exists("Results.xml")) { Containers.read_players_results(); } if (File.Exists("Sponsers.xml")) { Containers.Read_Sponsor(); } if (File.Exists("Admins.xml")) { Containers.Read_Admin(); } if (File.Exists("Expenses.xml")) { Expense.read_expense(); } }
private void button_Click(object sender, RoutedEventArgs e) { if (Teamname.Text == "") { MessageBox.Show("Please fill the required information !"); } else { bool clubbl = false; for (int i = 0; i < Containers.Club_list.Count; i++) { if (Teamname.Text == Containers.Club_list[i].getClubName()) { clubbl = true; } } if (clubbl == false) { MessageBox.Show("Club doesn't exist ! "); } else { for (int i = 0; i < Containers.Player_list.Count; i++) { if (Containers.Player_list[i].getId().ToString() == Enter_ID.playerid) { Containers.Player_list[i].setclubName(Teamname.Text); } } if (File.Exists("Players.xml")) { File.Delete("Players.xml"); } for (int i = 0; i < Containers.Player_list.Count; i++) { Containers.write_Player(Containers.Player_list[i]); } MessageBox.Show("Changes Done"); } } }
private void button1_Click(object sender, RoutedEventArgs e) { 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)); } } 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("Changes Done"); }
public departmentstat() { if (File.Exists("Employees.xml")) { Containers.Read_Employees(); } Dictionary <string, float> departmentSalaries = new Dictionary <string, float>(); Dictionary <string, int> departmentFrequency = new Dictionary <string, int>(); foreach (Employee employee in Containers.Employee_list) { if (departmentSalaries.ContainsKey(employee.GetDepartment())) { departmentSalaries[employee.GetDepartment()] += employee.getSalary(); departmentFrequency[employee.GetDepartment()]++; } else { departmentSalaries.Add(employee.GetDepartment(), employee.getSalary()); departmentFrequency.Add(employee.GetDepartment(), 1); } List <string> Keys = new List <string>(departmentSalaries.Keys); foreach (string department in Keys) { departmentSalaries[department] = departmentFrequency[department]; } Data = new SeriesCollection { new LineSeries { Values = new ChartValues <float>(departmentSalaries.Values) } }; Labels = new List <string>(departmentSalaries.Keys); InitializeComponent(); dep.Series = Data; horizontalAxis.Labels = Labels; } }
private void button1_Click(object sender, RoutedEventArgs e) { bool found = false; if (textBox.Text == "" || password.Text == "") { MessageBox.Show("Please fill the required information !"); } 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].Getpassword() == password.Text) { found = true; } Containers.Employee_list[i].setpassword(password.Text); } } if (found == false) { MessageBox.Show("Wrong Password "); } 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("Changes Done"); this.Hide(); } }
private void delete_Click(object sender, RoutedEventArgs e) { bool find = false; if (id.Text == "") { MessageBox.Show("Please Enter ID"); } else { for (int i = 0; i < Containers.Player_list.Count; i++) { if (Containers.Player_list[i].getId() == id.Text) { Containers.Player_list.Remove(Containers.Player_list[i]); find = true; } } if (find == false) { MessageBox.Show("Wrong ID"); } else { if (File.Exists("Players.xml")) { File.Delete("Players.xml"); } for (int i = 0; i < Containers.Player_list.Count; i++) { Containers.write_Player(Containers.Player_list[i]); } MessageBox.Show("Successfuly Deleted"); } } }
private void button1_Click(object sender, RoutedEventArgs e) { bool mobiles = false; for (int i = 0; i < Containers.Player_list.Count(); i++) { if (Containers.Player_list[i].getId().ToString() == Enter_ID.playerid) { if (Containers.Player_list[i].getmobile() == textBox1.Text) { mobiles = true; } } } bool mobile = false; for (int i = 0; i < Containers.Employee_list.Count(); i++) { if (Containers.Employee_list[i].getmobile() == mobilee.Text) { mobile = true; } } for (int i = 0; i < Containers.Player_list.Count(); i++) { if (Containers.Player_list[i].getmobile() == mobilee.Text) { mobile = true; } } if (mobile == true) { MessageBox.Show("Please Re-enter Mobile Number !"); } else if (textBox1.Text == "" || mobilee.Text == "") { MessageBox.Show("Please fill the required information !"); } else if (mobiles == false) { MessageBox.Show("Wrong Old Mobile Number"); } else if (mobilee.Text.Length != 11) { MessageBox.Show("Please Enter Valid Mobile Number!"); } else { for (int i = 0; i < Containers.Player_list.Count; i++) { if (Containers.Player_list[i].getId().ToString() == Enter_ID.playerid) { Containers.Player_list[i].setmobile(mobilee.Text); } } if (File.Exists("Players.xml")) { File.Delete("Players.xml"); } for (int i = 0; i < Containers.Player_list.Count; i++) { Containers.write_Player(Containers.Player_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 button1_Click(object sender, RoutedEventArgs e) { if (choose.Text == "Mobile_Number") { Edit_MobileNumberEmployee ee = new Edit_MobileNumberEmployee(); ee.Show(); this.Hide(); } else if (choose.Text == "Salary") { Edit_DepartmentSalaryBonus z = new Edit_DepartmentSalaryBonus(); z.Show(); this.Hide(); } else if (choose.Text == "Bonus") { for (int i = 0; i < Containers.Employee_list.Count(); i++) { float bonu = 0; if (Containers.Employee_list[i].getId() == Enter_ID_Employee.employeeeid) { int x = Containers.Employee_list[i].Working_year_calc(); float per = x / 5; if (x > 5) { bonu = (per * Containers.Employee_list[i].getSalary()) / 100; } } Containers.Employee_list[i].setbonus(bonu); } 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("Changes Done"); } else if (choose.Text == "Department") { Edit_DepartmentSalaryBonus z = new Edit_DepartmentSalaryBonus(); z.Show(); this.Hide(); } else if (choose.Text == "Avaliable") { Edit_Avaliable g = new Edit_Avaliable(); g.Show(); this.Hide(); } else if (choose.Text == "Password") { Edit_EmployeePassword ee = new Edit_EmployeePassword(); ee.Show(); this.Hide(); } }
public DoughnutChartExample() { InitializeComponent(); if (File.Exists("Employees.xml")) { Containers.Read_Employees(); } Dictionary <string, float> departmentSalaries = new Dictionary <string, float>(); Dictionary <string, int> departmentFrequency = new Dictionary <string, int>(); // Initializing Each Department Accumulative Salary foreach (Employee employee in Containers.Employee_list) { if (departmentSalaries.ContainsKey(employee.GetDepartment())) { departmentSalaries[employee.GetDepartment()] += employee.getSalary(); departmentFrequency[employee.GetDepartment()]++; } else { departmentSalaries.Add(employee.GetDepartment(), employee.getSalary()); departmentFrequency.Add(employee.GetDepartment(), 1); } } // Calculating the Median of the Salaries List <string> Keys = new List <string>(departmentSalaries.Keys); foreach (string department in Keys) { departmentSalaries[department] = departmentFrequency[department]; } SeriesCollection = new SeriesCollection { new PieSeries { Title = "HR", Values = new ChartValues <ObservableValue> { new ObservableValue(departmentFrequency["HR"]) }, DataLabels = true }, new PieSeries { Title = "Coach", Values = new ChartValues <ObservableValue> { new ObservableValue(departmentFrequency["Coach"]) }, DataLabels = true }, new PieSeries { Title = "Accounting", Values = new ChartValues <ObservableValue> { new ObservableValue(departmentFrequency["Accounting"]) }, DataLabels = true }, }; //adding values or series will update and animate the chart automatically //SeriesCollection.Add(new PieSeries()); //SeriesCollection[0].Values.Add(5); DataContext = this; }
private void button1_Click(object sender, RoutedEventArgs e) { bool found = false; if (textBox.Text == "" || password.Text == "") { MessageBox.Show("Please fill the required information !"); } else if (password.Text.Length < 6) { MessageBox.Show("Password Is Too Short !"); } else if (textBox.Text == password.Text) { MessageBox.Show("Enter Diffrent Password "); } else { for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId().ToString() == employeelogin.loginid) { if (Containers.Employee_list[i].Getpassword() == textBox.Text) { found = true; Containers.Employee_list[i].setpassword(password.Text); } } } if (found == false) { MessageBox.Show("Wrong Password "); } 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("Changes Done"); if (Loginas.bu == "yes") { if (employeelogin.Notification == true || employeelogin.depnoti == true || employeelogin.salnoti == true) { ggg = true; adminoptionNotification s = new adminoptionNotification(); s.Show(); this.Close(); } else { ggg = true; adminoptions s = new adminoptions(); s.Show(); this.Close(); } } else { if (employeelogin.Notification == true || employeelogin.depnoti == true || employeelogin.salnoti == true) { AccountingoptionNotification aa = new AccountingoptionNotification(); aa.Show(); this.Close(); } else { AccountingOptionForm aa = new AccountingOptionForm(); aa.Show(); this.Close(); } } } } }
private void button_Click(object sender, RoutedEventArgs e) { if (player_name.Text == "" || Number.Text == "" || names.Text == "" || Date.Text == "" || club.Text == "") { MessageBox.Show("Please fill the required information !"); } else if (Number.Text.Length != 11) { MessageBox.Show("Please Enter Valid Mobile Number!"); } else if ((male.IsChecked == true) && (female.IsChecked == true)) { MessageBox.Show("Please fill the required information !"); } else if ((yes.IsChecked == true) && (no.IsChecked == true)) { MessageBox.Show("Please fill the required information !"); } else { string gender; string med; int x = 0; string bou = x.ToString(); int y = int.Parse(Date.Text.Substring(6)); string salaryy = "0"; if (names.Text == "Women" || names.Text == "Men") { salaryy = "2000"; } if (male.IsChecked == true) { gender = "Male"; } else { gender = "Female"; } if (yes.IsChecked == true) { med = "YES"; } else { med = "NO"; } string temp = Date.Text; string temp2 = player_name.Text; string id = ""; bool mobile = false; Person.count2++; if (temp.Length == 10) { id = Person.count2 + temp2[0].ToString() + temp2[1].ToString() + temp[8].ToString() + temp[9].ToString(); } else if (temp.Length == 9) { id = Person.count2 + temp2[0].ToString() + temp2[1].ToString() + temp[7].ToString() + temp[8].ToString(); } else if (temp.Length == 8) { id = Person.count2 + temp2[0].ToString() + temp2[1].ToString() + temp[6].ToString() + temp[7].ToString(); } Player p = new Player(player_name.Text, Date.Text, gender, id, med, float.Parse(salaryy), x, Number.Text, names.Text, coach.Text, club.Text); bool mobilee = false; for (int i = 0; i < Containers.Player_list.Count(); i++) { if (Containers.Player_list[i].getmobile() == Number.Text) { mobilee = true; } } for (int i = 0; i < Containers.Employee_list.Count(); i++) { if (Containers.Employee_list[i].getmobile() == Number.Text) { mobilee = true; } } bool coachh = false, clubbl = false; for (int i = 0; i < Containers.Club_list.Count; i++) { if (club.Text == Containers.Club_list[i].getClubName()) { clubbl = true; } } for (int i = 0; i < Containers.Coach_list.Count; i++) { if (coach.Text == Containers.Coach_list[i].getName()) { coachh = true; } } if (mobilee == true) { MessageBox.Show("Please Re-enter Mobile Number !"); } else if (coachh == false) { MessageBox.Show("Coach doesn't exist ! "); } else if (clubbl == false) { MessageBox.Show("Club Does not Exists !"); } else { Containers.Player_list.Add(p); if (!File.Exists("Players.xml")) { XmlTextWriter document = new XmlTextWriter("Players.xml", Encoding.UTF8); document.Formatting = Formatting.Indented; document.WriteStartDocument(); document.WriteStartElement("Players"); document.WriteStartElement("Player"); document.WriteStartElement("Player_Name"); document.WriteString(player_name.Text); document.WriteEndElement(); document.WriteStartElement("Player_ID"); document.WriteString(id); document.WriteEndElement(); document.WriteStartElement("Mobile_Number"); document.WriteString(Number.Text); document.WriteEndElement(); document.WriteStartElement("Gender"); document.WriteString(gender); document.WriteEndElement(); document.WriteStartElement("Medical_Form"); document.WriteString(med); document.WriteEndElement(); document.WriteStartElement("Salary"); document.WriteString(salaryy); document.WriteEndElement(); document.WriteStartElement("Bonus"); document.WriteString(bou); document.WriteEndElement(); document.WriteStartElement("Date_of_birth"); document.WriteString(Date.Text); document.WriteEndElement(); document.WriteStartElement("Team_Name"); document.WriteString(names.Text); document.WriteEndElement(); document.WriteStartElement("Coach_Name"); document.WriteString(coach.Text); document.WriteEndElement(); document.WriteStartElement("Club_Name"); document.WriteString(club.Text); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndDocument(); document.Close(); MessageBox.Show("Player Successfuly Added."); } else { XmlDocument doc = new XmlDocument(); doc.Load("Players.xml"); XmlNode playerr = doc.CreateElement("Player"); XmlNode Player_Name = doc.CreateElement("Player_Name"); Player_Name.InnerText = player_name.Text; playerr.AppendChild(Player_Name); XmlNode ID = doc.CreateElement("Player_ID"); ID.InnerText = id; playerr.AppendChild(ID); XmlNode MobileNum = doc.CreateElement("Mobile_Number"); MobileNum.InnerText = Number.Text; playerr.AppendChild(MobileNum); XmlNode Genderr = doc.CreateElement("Gender"); Genderr.InnerText = gender; playerr.AppendChild(Genderr); XmlNode Medical = doc.CreateElement("Medical_Form"); Medical.InnerText = med; playerr.AppendChild(Medical); XmlNode salary = doc.CreateElement("Salary"); salary.InnerText = salaryy; playerr.AppendChild(salary); XmlNode bonus = doc.CreateElement("Bonus"); bonus.InnerText = bou; playerr.AppendChild(bonus); XmlNode dateofbirth = doc.CreateElement("Date_oF_birth"); dateofbirth.InnerText = Date.Text; playerr.AppendChild(dateofbirth); XmlNode teamm = doc.CreateElement("Team_Name"); teamm.InnerText = names.Text; playerr.AppendChild(teamm); XmlNode cooo = doc.CreateElement("Coach_Name"); cooo.InnerText = coach.Text; playerr.AppendChild(cooo); XmlNode clubb = doc.CreateElement("Club_Name"); clubb.InnerText = club.Text; playerr.AppendChild(clubb); doc.DocumentElement.AppendChild(playerr); doc.Save("Players.xml"); MessageBox.Show("Player Successfuly Added."); } Containers.write_counter2(); } } }
private void ADD_Click(object sender, RoutedEventArgs e) { if (Name.Text == "" || number.Text == "" || Salary.Text == "" || Emplyedate.Text == "" || Date.Text == "" || Department.Text == "") { MessageBox.Show("Please fill the required information !"); } else if ((Male.IsChecked == false) && (Female.IsChecked == false)) { MessageBox.Show("Please fill the required information !"); } else if ((Yes.IsChecked == false) && (No.IsChecked == false)) { MessageBox.Show("Please fill the required information !"); } else if ((Yes3.IsChecked == false) && (No3.IsChecked == false)) { MessageBox.Show("Please fill the required information !"); } else if (number.Text.Length != 11) { MessageBox.Show("Please Enter Valid Mobile Number!"); } else { string dep = ""; if (Department.Text == "HR") { if (adminlogin.admin == true) { dep = "HR"; } } else if (Department.Text == "Coach") { dep = "Coach"; } else if (Department.Text == "Accounting") { dep = "Accounting"; } string gender = ""; string med; string avail; int y = int.Parse(Emplyedate.Text.Substring(6)); double sal = double.Parse(Salary.Text); DateTime doe = Convert.ToDateTime(Emplyedate.Text); int yyear = doe.Year; int today = DateTime.Today.Year; int x = today - yyear; string working_years = x.ToString(); double bon = 0; if (x > 5) { double b = x / 5; bon = ((b * 0.2) * sal); } string temp = Date.Text; string temp2 = Name.Text; string id = ""; // temp2[0].ToString() + temp2[1].ToString() + temp[temp.Count() - 2].ToString() + temp[temp.Count()-1].ToString(); Person.count1++; if (temp.Length == 10) { id = Person.count1 + temp2[0].ToString() + temp2[1].ToString() + temp[8].ToString() + temp[9].ToString(); } else if (temp.Length == 9) { id = Person.count1 + temp2[0].ToString() + temp2[1].ToString() + temp[7].ToString() + temp[8].ToString(); } else if (temp.Length == 8) { id = Person.count1 + temp2[0].ToString() + temp2[1].ToString() + temp[6].ToString() + temp[7].ToString(); } string generatedpass = id; if (Male.IsChecked == true) { gender = "Male"; } else { gender = "Female"; } if (Yes.IsChecked == true) { med = "YES"; } else { med = "NO"; } if (Yes3.IsChecked == true) { avail = "Yes"; } else { avail = "No"; } Employee emp = new Employee(Name.Text, Date.Text, gender, id, med, float.Parse(Salary.Text), 0, number.Text, x, Emplyedate.Text, avail, dep, generatedpass, "NO", "NO"); bool mobile = false; for (int i = 0; i < Containers.Employee_list.Count(); i++) { if (Containers.Employee_list[i].getmobile() == number.Text) { mobile = true; } } for (int i = 0; i < Containers.Player_list.Count(); i++) { if (Containers.Player_list[i].getmobile() == number.Text) { mobile = true; } } if (mobile == true) { MessageBox.Show("Please Re-enter Mobile Number !"); } else { Containers.Employee_list.Add(emp); if (dep != "") { if (!File.Exists("Employees.xml")) { XmlTextWriter document = new XmlTextWriter("Employees.xml", Encoding.UTF8); document.Formatting = Formatting.Indented; document.WriteStartDocument(); document.WriteStartElement("Employees"); document.WriteStartElement("Employee"); document.WriteStartElement("Employee_Name"); document.WriteString(Name.Text); document.WriteEndElement(); document.WriteStartElement("Employment_ID"); document.WriteString(id); document.WriteEndElement(); document.WriteStartElement("Mobile_Number"); document.WriteString(number.Text); document.WriteEndElement(); document.WriteStartElement("Gender"); document.WriteString(gender); document.WriteEndElement(); document.WriteStartElement("Medical_Form"); document.WriteString(med); document.WriteEndElement(); document.WriteStartElement("Salary"); document.WriteString(Salary.Text); document.WriteEndElement(); document.WriteStartElement("Bonus"); document.WriteString(bon.ToString()); document.WriteEndElement(); document.WriteStartElement("Employement_Date"); document.WriteString(Emplyedate.Text); document.WriteEndElement(); document.WriteStartElement("Working_Years"); document.WriteString(working_years); document.WriteEndElement(); document.WriteStartElement("Date_of_birth"); document.WriteString(Date.Text); document.WriteEndElement(); document.WriteStartElement("Available"); document.WriteString(avail); document.WriteEndElement(); document.WriteStartElement("Department"); document.WriteString(dep); document.WriteEndElement(); document.WriteStartElement("Password"); document.WriteString(generatedpass); document.WriteEndElement(); document.WriteStartElement("Salary_Notification"); document.WriteString("NO"); document.WriteEndElement(); document.WriteStartElement("Department_Notification"); document.WriteString("NO"); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndDocument(); document.Close(); MessageBox.Show("Employee Successfuly Added."); } else { XmlDocument doc = new XmlDocument(); doc.Load("Employees.xml"); XmlNode employee = doc.CreateElement("Employee"); XmlNode Employee_Name = doc.CreateElement("Employee_Name"); Employee_Name.InnerText = Name.Text; employee.AppendChild(Employee_Name); XmlNode Employee_ID = doc.CreateElement("Employeement_ID"); Employee_ID.InnerText = id; employee.AppendChild(Employee_ID); XmlNode MobileNum = doc.CreateElement("Mobile_Number"); MobileNum.InnerText = number.Text; employee.AppendChild(MobileNum); XmlNode Genderr = doc.CreateElement("Gender"); Genderr.InnerText = gender; employee.AppendChild(Genderr); XmlNode Medical = doc.CreateElement("Medical_Form"); Medical.InnerText = med; employee.AppendChild(Medical); XmlNode salary = doc.CreateElement("Salary"); salary.InnerText = Salary.Text; employee.AppendChild(salary); XmlNode b = doc.CreateElement("Bonus"); b.InnerText = bon.ToString(); employee.AppendChild(b); XmlNode Employementdate = doc.CreateElement("Employement_Date"); Employementdate.InnerText = Emplyedate.Text; employee.AppendChild(Employementdate); XmlNode workingyears = doc.CreateElement("Working_Years"); workingyears.InnerText = working_years; employee.AppendChild(workingyears); XmlNode dateofbirth = doc.CreateElement("Date_of_birth"); dateofbirth.InnerText = Date.Text; employee.AppendChild(dateofbirth); XmlNode avaliable = doc.CreateElement("Available"); avaliable.InnerText = avail; employee.AppendChild(avaliable); XmlNode depp = doc.CreateElement("Department"); depp.InnerText = Department.Text; employee.AppendChild(depp); XmlNode pas = doc.CreateElement("Password"); pas.InnerText = generatedpass; employee.AppendChild(pas); XmlNode saln = doc.CreateElement("Salary_Notification"); saln.InnerText = "NO"; employee.AppendChild(saln); XmlNode depnot = doc.CreateElement("Department_Notification"); depnot.InnerText = "NO"; employee.AppendChild(depnot); doc.DocumentElement.AppendChild(employee); doc.Save("Employees.xml"); MessageBox.Show("Employee Successfuly Added."); } if (Department.Text == "Coach") { if (!File.Exists("Coaches.xml")) { XmlTextWriter document = new XmlTextWriter("Coaches.xml", Encoding.UTF8); document.Formatting = Formatting.Indented; document.WriteStartDocument(); document.WriteStartElement("Coaches"); document.WriteStartElement("Coach"); document.WriteStartElement("Coach_Name"); document.WriteString(Name.Text); document.WriteEndElement(); document.WriteStartElement("Coach_ID"); document.WriteString(id); document.WriteEndElement(); document.WriteStartElement("Mobile_Number"); document.WriteString(number.Text); document.WriteEndElement(); document.WriteStartElement("Gender"); document.WriteString(gender); document.WriteEndElement(); document.WriteStartElement("Medical_Form"); document.WriteString(med); document.WriteEndElement(); document.WriteStartElement("Salary"); document.WriteString(Salary.Text); document.WriteEndElement(); document.WriteStartElement("Bonus"); document.WriteString(bon.ToString()); document.WriteEndElement(); document.WriteStartElement("Employement_Date"); document.WriteString(Emplyedate.Text); document.WriteEndElement(); document.WriteStartElement("Working_Years"); document.WriteString(working_years); document.WriteEndElement(); document.WriteStartElement("Date_of_birth"); document.WriteString(Date.Text); document.WriteEndElement(); document.WriteStartElement("Available"); document.WriteString(avail); document.WriteEndElement(); document.WriteStartElement("Department"); document.WriteString(dep); document.WriteEndElement(); document.WriteStartElement("Results"); document.WriteString("0"); document.WriteEndElement(); document.WriteStartElement("Password"); document.WriteString(generatedpass); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndDocument(); document.Close(); MessageBox.Show("Coach Successfuly Added."); } else { XmlDocument doc = new XmlDocument(); doc.Load("Coaches.xml"); XmlNode employee = doc.CreateElement("Coach"); XmlNode Employee_Name = doc.CreateElement("Coach_Name"); Employee_Name.InnerText = Name.Text; employee.AppendChild(Employee_Name); XmlNode Employee_ID = doc.CreateElement("Coach_ID"); Employee_ID.InnerText = id; employee.AppendChild(Employee_ID); XmlNode MobileNum = doc.CreateElement("Mobile_Number"); MobileNum.InnerText = number.Text; employee.AppendChild(MobileNum); XmlNode Genderr = doc.CreateElement("Gender"); Genderr.InnerText = gender; employee.AppendChild(Genderr); XmlNode Medical = doc.CreateElement("Medical_Form"); Medical.InnerText = med; employee.AppendChild(Medical); XmlNode salary = doc.CreateElement("Salary"); salary.InnerText = Salary.Text; employee.AppendChild(salary); XmlNode b = doc.CreateElement("Bonus"); b.InnerText = bon.ToString(); employee.AppendChild(b); XmlNode Employementdate = doc.CreateElement("Employement_Date"); Employementdate.InnerText = Emplyedate.Text; employee.AppendChild(Employementdate); XmlNode workingyears = doc.CreateElement("Working_Years"); workingyears.InnerText = working_years; employee.AppendChild(workingyears); XmlNode dateofbirth = doc.CreateElement("Date_of_birth"); dateofbirth.InnerText = Date.Text; employee.AppendChild(dateofbirth); XmlNode avaliable = doc.CreateElement("Available"); avaliable.InnerText = avail; employee.AppendChild(avaliable); XmlNode depp = doc.CreateElement("Department"); depp.InnerText = dep; employee.AppendChild(depp); XmlNode res = doc.CreateElement("Results"); res.InnerText = "0"; employee.AppendChild(res); XmlNode pas = doc.CreateElement("Password"); pas.InnerText = generatedpass; employee.AppendChild(pas); doc.DocumentElement.AppendChild(employee); doc.Save("Coaches.xml"); MessageBox.Show("Coach Successfuly Added."); } } Containers.write_counter1(); } else { MessageBox.Show("You're not allowed to add HR !"); } } } }
private void button_Click(object sender, RoutedEventArgs e) { List <Player> l = Containers.Player_list; for (int i = 0; i < l.Count; i++) { for (int j = i + 1; j < l.Count; j++) { if (l[i].get_results() < l[j].get_results()) { Player tmp = l[i]; l[i] = l[j]; l[j] = tmp; } } } List <string> pname = new List <string>(); List <int> presult = new List <int>(); List <string> pgender = new List <string>(); List <string> page = new List <string>(); for (int k = 0; k < 5; k++) { if (l[k].getGender() == "Male") { l[k].setbonus(1000); } } for (int k = 0; k < 5; k++) { if (l[k].getGender() == "Female") { l[k].setbonus(1000); } } if (File.Exists("Players.xml")) { File.Delete("Players.xml"); } for (int j = 0; j < Containers.Player_list.Count; j++) { Containers.write_Player(Containers.Player_list[j]); } if (male.IsChecked == true) { for (int i = 0; i < l.Count; i++) { if (l[i].getGender() == "Male") { pname.Add(l[i].getName()); presult.Add(l[i].get_results()); pgender.Add(l[i].getGender()); if (l[i].ageCalculator() >= 18) { page.Add("Senior"); } else { page.Add("Junior"); } } } } else if (female.IsChecked == true) { for (int i = 0; i < l.Count; i++) { if (l[i].getGender() == "Female") { pname.Add(l[i].getName()); presult.Add(l[i].get_results()); pgender.Add(l[i].getGender()); if (l[i].ageCalculator() >= 18) { page.Add("Senior"); } else { page.Add("Junior"); } } } } else { MessageBox.Show("Please Choose An Option !"); } listBox.ItemsSource = pname; listBox1.ItemsSource = presult; listBox3.ItemsSource = pgender; listBox2.ItemsSource = page; }
private void button2_Click_1(object sender, RoutedEventArgs e) { bool valid = false; loginid = login.Text; loginpass = passwordBox.Password; for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId() == login.Text) { if (Containers.Employee_list[i].GetDepartment() == "Coach") { empid = true; } } } bool x = false, y = false; for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId() == login.Text && Containers.Employee_list[i].Getpassword() == passwordBox.Password) { if (Containers.Employee_list[i].GetDepartment() == "Accounting") { if (Loginas.bu == "yes") { x = true; break; } } } } for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].GetDepartment() == "HR") { if (Containers.Employee_list[i].getId() == login.Text && Containers.Employee_list[i].Getpassword() == passwordBox.Password) { if (Loginas.au == "yes") { y = true; break; } } } } if (x == true || y == true) { MessageBox.Show("Wrong ID or Password"); } else { for (int i = 0; i < Containers.Employee_list.Count; i++) { if (Containers.Employee_list[i].getId() == login.Text && Containers.Employee_list[i].Getpassword() == passwordBox.Password) { Containers.Employee_list[i].setStatus("YES"); if (Containers.Employee_list[i].getMedicalReport() == "NO") { Notification = true; } if (Containers.Employee_list[i].getdepnot() == "YES") { depnoti = true; Containers.Employee_list[i].setdepnot("NO"); } if (Containers.Employee_list[i].getsalarynot() == "YES") { salnoti = true; Containers.Employee_list[i].setsalarynot("NO"); } if (Containers.Employee_list[i].GetDepartment() == "Coach") { break; } MessageBox.Show("Login Successfuly."); if (Containers.Employee_list[i].GetDepartment() == "HR") { if (login.Text == passwordBox.Password) { Edit_EmployeePassword eee = new Edit_EmployeePassword(); eee.Show(); } else { if (Notification == true || depnoti == true || salnoti == true) { adminoptionNotification oo = new adminoptionNotification(); hrid = true; oo.Show(); } else { adminoptions oo = new adminoptions(); hrid = true; oo.Show(); } } this.Close(); } else if (Containers.Employee_list[i].GetDepartment() == "Accounting") { if (login.Text == passwordBox.Password) { Edit_EmployeePassword eee = new Edit_EmployeePassword(); eee.Show(); } else { if (Notification == true || depnoti == true || salnoti == true) { AccountingoptionNotification af = new AccountingoptionNotification(); af.Show(); } else { AccountingOptionForm af = new AccountingOptionForm(); af.Show(); } } this.Close(); } valid = true; 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 (!valid) { MessageBox.Show("Wrong ID or Password!"); } } }