Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace lab4
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- empList = new List<Employee> { new Employee(1,"Bauja","CEO"),
- new Employee(2,"Estate","Mdivani"),
- new Employee(3,"Test","test1")};
- salList = new List<Salary> { new Salary(1,1,9,"Monthly salary",7000),
- new Salary(2,1,10,"Bonus",5000),
- new Salary(3,2,9,"Requested Checkout",4000),
- new Salary(4,2,10,"Shvebuleba salary",6000),
- new Salary(5,3,10,"Loan",1000)};
- empList[0].salaryList.Add(salList[0]);
- empList[0].salaryList.Add(salList[1]);
- empList[1].salaryList.Add(salList[2]);
- empList[1].salaryList.Add(salList[3]);
- empList[2].salaryList.Add(salList[4]);
- }
- List<Employee> empList;
- List<Salary> salList;
- private void label2_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- empList.Add(new Employee(Convert.ToInt32(textBox1.Text), textBox2.Text, textBox3.Text));
- MessageBox.Show("Employee has been added");
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Salary newsal = new Salary(Convert.ToInt32(textBox4.Text),Convert.ToInt32(textBox5.Text),Convert.ToInt32(textBox6.Text),textBox7.Text,Convert.ToDouble(textBox8.Text));
- salList.Add(newsal);
- empList[Convert.ToInt32(textBox5.Text)-1].salaryList.Add(newsal);
- MessageBox.Show("Salary has been added");
- }
- private void button3_Click(object sender, EventArgs e)
- {
- double tot = 0;
- var totalSal = from emp in empList
- where emp.EmpID == Convert.ToInt32(textBox9.Text)
- select emp;
- foreach (Employee emp in totalSal)
- {
- for (int i = 0; i < emp.salaryList.Count; i++)
- {
- tot += emp.salaryList[i].amount;
- }
- }
- label13.Text = "Total salary of this employee is : " + tot.ToString();
- }
- }
- class Employee
- {
- public int EmpID;
- public string Name, Position;
- public List<Salary> salaryList = new List<Salary>();
- public Employee(int EmpID,string Name, string Position)
- {
- this.EmpID = EmpID;
- this.Name = Name;
- this.Position = Position;
- }
- }
- class Salary
- {
- public int ID, empID, numberOfMonth;
- public string PaymentType;
- public double amount;
- public Salary(int ID, int empID, int numberOfMonth, string PaymentType, double amount)
- {
- this.ID = ID;
- this.empID = empID;
- this.numberOfMonth = numberOfMonth;
- this.PaymentType = PaymentType;
- this.amount = amount;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement