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 NETLAB1Kabanchuk
- {
- class Employee
- {
- private string fio;
- private int salary;
- private int exp;
- private double ndfl;
- private double prize;
- public Employee(string fio, int salary, int exp)
- {
- this.fio = fio;
- this.salary = salary;
- this.exp = exp;
- }
- public string getFio() { return this.fio; }
- public int getSalary() { return this.salary; }
- public int getExp() { return this.exp; }
- public double getNDFL() { return this.ndfl; }
- public double getPrize() { return this.prize; }
- public void setNdfl(double ndfl) { this.ndfl = ndfl; }
- public void setPrize(double prize) { this.prize = prize; }
- }
- class Student
- {
- private string name;
- private int phone;
- private int[] marks;
- public Student(string name, int phone, int[] marks)
- {
- this.name = name;
- this.phone = phone;
- this.marks = marks;
- }
- public int getAverageMark()
- {
- int average = 0;
- for (int i = 0; i < marks.Length; i++)
- average += marks[i];
- return average / marks.Length;
- }
- public string getName() { return this.name; }
- public int getPhone() { return this.phone; }
- public int getMark(int index) { return this.marks[index]; }
- }
- public partial class Lab1 : Form
- {
- List<Student> Students = new List<Student>();
- List<Employee> Employees = new List<Employee>();
- public Lab1()
- {
- InitializeComponent();
- }
- public void listsInicialize()
- {
- Students.Add(new Student("Олег", 323545, new int[] { 1, 2, 3, 6, 8} ));
- Students.Add(new Student("Василий", 342345, new int[] { 4, 8, 6, 9, 10 }));
- Students.Add(new Student("Андрей", 78955, new int[] { 7, 2, 4, 2, 4 }));
- Students.Add(new Student("Максим", 88545, new int[] { 6, 5, 2, 5, 7 }));
- Students.Add(new Student("Владимир", 323545, new int[] { 5, 8, 3, 8, 2 }));
- Students.Add(new Student("Сергей", 342345, new int[] { 4, 6, 8, 6, 7 }));
- Students.Add(new Student("Егор", 78955, new int[] { 4, 2, 4, 2, 4 }));
- Students.Add(new Student("Валерий", 88545, new int[] { 2, 2, 2, 2, 2 }));
- Employees.Add(new Employee("Иванов Олег", 10000, 2));
- Employees.Add(new Employee("Борисов Василий", 50000, 3));
- Employees.Add(new Employee("Сергеев Андрей", 35000, 5));
- Employees.Add(new Employee("Турчин Максим", 90000, 10));
- Employees.Add(new Employee("Игорев Владимир", 25000, 20));
- Employees.Add(new Employee("Максимов Сергей", 60000, 15));
- Employees.Add(new Employee("Денисов Егор", 55000, 30));
- Employees.Add(new Employee("Сталин Валерий", 12000, 40));
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- DataTable table = new DataTable();
- table.Columns.Add("Имена");
- table.Columns.Add("Номера телефонов");
- table.Columns.Add("Математика");
- table.Columns.Add("Физика");
- table.Columns.Add("Биология");
- table.Columns.Add("География");
- table.Columns.Add("Информатика");
- table.Columns.Add("Средняя оценка");
- listsInicialize();
- for (int i = 0; i < Students.Count; i++)
- {
- table.Rows.Add(new String[] {
- Students[i].getName(),
- Convert.ToString(Students[i].getPhone()),
- Convert.ToString(Students[i].getMark(0)),
- Convert.ToString(Students[i].getMark(1)),
- Convert.ToString(Students[i].getMark(2)),
- Convert.ToString(Students[i].getMark(3)),
- Convert.ToString(Students[i].getMark(4)),
- });
- }
- dataGridView1.DataSource = table;
- DataTable table_e = new DataTable();
- table_e.Columns.Add("ФИО");
- table_e.Columns.Add("Оклад");
- table_e.Columns.Add("Стаж");
- table_e.Columns.Add("Итоговая ЗП");
- for (int i = 0; i < Employees.Count; i++)
- {
- table_e.Rows.Add(new String[] {
- Employees[i].getFio(),
- Employees[i].getSalary().ToString(),
- Employees[i].getExp().ToString(),
- });
- }
- dataGridView2.DataSource = table_e;
- }
- private void firstTableStart_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < Students.Count; i++)
- {
- int average = Students[i].getAverageMark();
- dataGridView1.Rows[i].Cells[7].Value = Students[i].getAverageMark();
- if (average > 4)
- dataGridView1.Rows[i].Cells[7].Style.BackColor = Color.FromName(colorsGood.SelectedItem.ToString());
- else if (average > 3)
- dataGridView1.Rows[i].Cells[7].Style.BackColor = Color.FromName(colorsAverage.SelectedItem.ToString());
- else
- dataGridView1.Rows[i].Cells[7].Style.BackColor = Color.FromName(colorsBad.SelectedItem.ToString());
- }
- }
- private void secondTableStart_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < Employees.Count; i++)
- {
- double salary = Employees[i].getSalary();
- double prize = 0;
- double exp = Employees[i].getExp();
- double ndfl = Convert.ToInt32(NDFL.Text);
- if (exp > 10)
- {
- prize = 20;
- Employees[i].setPrize((Employees[i].getSalary() * 20) / 100);
- }
- else if (exp > 5)
- {
- prize = 15;
- Employees[i].setPrize((Employees[i].getSalary() * 15) / 100);
- }
- else
- {
- prize = 10;
- Employees[i].setPrize((Employees[i].getSalary() * 10) / 100);
- }
- double result = (salary + (salary * (prize / 100))) - (salary * (ndfl / 100));
- dataGridView2.Rows[i].Cells[3].Value = result;
- Employees[i].setNdfl((salary*ndfl)/100);
- }
- }
- private void getLogsButton_Click(object sender, EventArgs e)
- {
- int index = (int)dataGridView2.CurrentRow.Index;
- MessageBox.Show(Employees[index].getFio() +
- ", НДФЛ = " + Employees[index].getNDFL() +
- ", Премия = " + Employees[index].getPrize()
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement