Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace lab4
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void Form1_Load(object sender, EventArgs e)
  21. {
  22.  
  23. empList = new List<Employee> { new Employee(1,"Bauja","CEO"),
  24. new Employee(2,"Estate","Mdivani"),
  25. new Employee(3,"Test","test1")};
  26. salList = new List<Salary> { new Salary(1,1,9,"Monthly salary",7000),
  27. new Salary(2,1,10,"Bonus",5000),
  28. new Salary(3,2,9,"Requested Checkout",4000),
  29. new Salary(4,2,10,"Shvebuleba salary",6000),
  30. new Salary(5,3,10,"Loan",1000)};
  31. empList[0].salaryList.Add(salList[0]);
  32. empList[0].salaryList.Add(salList[1]);
  33. empList[1].salaryList.Add(salList[2]);
  34. empList[1].salaryList.Add(salList[3]);
  35. empList[2].salaryList.Add(salList[4]);
  36. }
  37. List<Employee> empList;
  38. List<Salary> salList;
  39.  
  40. private void label2_Click(object sender, EventArgs e)
  41. {
  42.  
  43. }
  44.  
  45. private void button1_Click(object sender, EventArgs e)
  46. {
  47. empList.Add(new Employee(Convert.ToInt32(textBox1.Text), textBox2.Text, textBox3.Text));
  48. MessageBox.Show("Employee has been added");
  49. }
  50.  
  51. private void button2_Click(object sender, EventArgs e)
  52. {
  53. Salary newsal = new Salary(Convert.ToInt32(textBox4.Text),Convert.ToInt32(textBox5.Text),Convert.ToInt32(textBox6.Text),textBox7.Text,Convert.ToDouble(textBox8.Text));
  54. salList.Add(newsal);
  55. empList[Convert.ToInt32(textBox5.Text)-1].salaryList.Add(newsal);
  56. MessageBox.Show("Salary has been added");
  57. }
  58.  
  59. private void button3_Click(object sender, EventArgs e)
  60. {
  61. double tot = 0;
  62. var totalSal = from emp in empList
  63. where emp.EmpID == Convert.ToInt32(textBox9.Text)
  64. select emp;
  65. foreach (Employee emp in totalSal)
  66. {
  67. for (int i = 0; i < emp.salaryList.Count; i++)
  68. {
  69. tot += emp.salaryList[i].amount;
  70. }
  71. }
  72. label13.Text = "Total salary of this employee is : " + tot.ToString();
  73. }
  74. }
  75. class Employee
  76. {
  77. public int EmpID;
  78. public string Name, Position;
  79. public List<Salary> salaryList = new List<Salary>();
  80. public Employee(int EmpID,string Name, string Position)
  81. {
  82. this.EmpID = EmpID;
  83. this.Name = Name;
  84. this.Position = Position;
  85. }
  86. }
  87. class Salary
  88. {
  89. public int ID, empID, numberOfMonth;
  90. public string PaymentType;
  91. public double amount;
  92. public Salary(int ID, int empID, int numberOfMonth, string PaymentType, double amount)
  93. {
  94. this.ID = ID;
  95. this.empID = empID;
  96. this.numberOfMonth = numberOfMonth;
  97. this.PaymentType = PaymentType;
  98. this.amount = amount;
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement