Пример #1
0
        /// <summary>
        /// Расчетный лист за текущий месяц в виде для филиала F и подразделения S (указывается пользователем)
        /// в виде списка сотрудников в алфавитном порядке с указанием суммы зарплаты
        /// </summary>
        private void printReport4(Enterprise enterprise)
        {
            try
            {
                using (StreamWriter sw = new StreamWriter(string.Format(Application.StartupPath.ToString() + "\\Отчеты\\{0}.txt", 4), false, System.Text.Encoding.Default))
                {
                    if (comboBoxF.SelectedItem != null && comboBoxPodr.SelectedItem != null)
                    {
                        Filiation filial = BaseEnterprise.Filiations.Find(x => x.Name.Contains(comboBoxF.SelectedItem.ToString()));
                        Unit      unit   = filial.Units.Find(x => x.Name.Contains(comboBoxPodr.SelectedItem.ToString()));

                        foreach (Employee elemE in unit.Employees.OrderBy(x => x.EmployeeFIO.Surname))
                        {
                            sw.WriteLine(elemE.EmployeeFIO.Surname + " "
                                         + elemE.EmployeeFIO.Name + " "
                                         + elemE.EmployeeFIO.Pathronymic + ": "
                                         + elemE.SumSalary);
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                Console.WriteLine();
            }
        }
Пример #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textBoxName.Text) &&
         !string.IsNullOrEmpty(textBoxSurname.Text) &&
         !string.IsNullOrEmpty(textBoxPathronymic.Text) &&
         listBoxUnits.SelectedIndex != -1)
     {
         Filiation filial   = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
         Unit      unit     = filial.Units.Find(x => x.Name.Contains(listBoxUnits.SelectedItem.ToString()));
         Employee  employee = unit.Employees.Find(x =>
                                                  (x.EmployeeFIO.Name.Contains(textBoxName.Text)) &&
                                                  x.EmployeeFIO.Surname.Contains(textBoxSurname.Text) &&
                                                  x.EmployeeFIO.Pathronymic.Contains(textBoxPathronymic.Text)
                                                  );
         if (employee != null)
         {
             employee.TypeSalary = comboBoxType.SelectedItem.ToString();
             employee.Salary     = decimal.Parse(textBoxSalary.Text, new NumberFormatInfo {
                 NumberDecimalSeparator = "."
             });
             employee.Time = decimal.Parse(textBoxCountHour.Text, new NumberFormatInfo {
                 NumberDecimalSeparator = "."
             });
         }
         listBoxEmployee.Items.Clear();
         ShowEmployee(unit);
     }
     else
     {
         MessageBox.Show("Необходимо заполнить все поля и выбрать подразделение.");
     }
 }
Пример #3
0
 private void button_DeleteFiliation_Click(object sender, EventArgs e)
 {
     if (listBoxFiliations.SelectedItem != null)
     {
         Filiation filial = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
         enterpriseBase.Filiations.Remove(filial);
     }
     ShowFiliations();
 }
Пример #4
0
 private void listBoxFiliations_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxFiliations.SelectedItem != null)
     {
         Filiation filiation = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
         textBoxNameFiliation.Text    = filiation.Name;
         textBoxAddressFiliation.Text = filiation.Address;
         ShowUnits(filiation);
     }
 }
Пример #5
0
 private void ShowUnits(Filiation filiation)
 {
     listBoxUnits.Items.Clear();
     listBoxEmployee.Items.Clear();
     foreach (Unit elem in filiation.Units)
     {
         listBoxUnits.Items.Add(elem.Name);
         ShowEmployee(elem);
     }
 }
Пример #6
0
 private void button_DeleteUnit_Click(object sender, EventArgs e)
 {
     if (listBoxFiliations.SelectedItem != null && listBoxUnits.SelectedItem != null)
     {
         Filiation filial = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
         Unit      unit   = filial.Units.Find(x => x.Name.Contains(listBoxUnits.SelectedItem.ToString()));
         filial.Units.Remove(unit);
         ShowUnits(filial);
     }
 }
Пример #7
0
        private void comboBoxF_SelectedIndexChanged(object sender, EventArgs e)
        {
            Filiation filial = BaseEnterprise.Filiations.Find(x => x.Name.Contains(comboBoxF.SelectedItem.ToString()));

            comboBoxPodr.Items.Clear();
            foreach (Unit elem in filial.Units)
            {
                comboBoxPodr.Items.Add(elem.Name);
            }
        }
Пример #8
0
 private void listBoxUnits_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxFiliations.SelectedItem != null && listBoxUnits.SelectedItem != null)
     {
         Filiation filial = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
         Unit      unit   = filial.Units.Find(x => x.Name.Contains(listBoxUnits.SelectedItem.ToString()));
         textBoxNameUnit.Text = unit.Name;
         listBoxEmployee.Items.Clear();
         ShowEmployee(unit);
     }
 }
Пример #9
0
        private void button_DeleteEmployee_Click(object sender, EventArgs e)
        {
            if (listBoxFiliations.SelectedItem != null &&
                listBoxUnits.SelectedItem != null &&
                listBoxEmployee.SelectedItem != null)
            {
                string   fio    = listBoxEmployee.SelectedItem.ToString();
                string[] masFIO = fio.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Filiation filial   = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
                Unit      unit     = filial.Units.Find(x => x.Name.Contains(listBoxUnits.SelectedItem.ToString()));
                Employee  employee = unit.Employees.Find(x => x.EmployeeFIO.Name.Contains(masFIO[0]) &&
                                                         x.EmployeeFIO.Surname.Contains(masFIO[1]) &&
                                                         x.EmployeeFIO.Pathronymic.Contains(masFIO[2]));
                unit.Employees.Remove(employee);
                listBoxEmployee.Items.Clear();
                ShowEmployee(unit);
            }
        }
Пример #10
0
        private void button_AddEmployee_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBoxName.Text) &&
                !string.IsNullOrEmpty(textBoxSurname.Text) &&
                !string.IsNullOrEmpty(textBoxPathronymic.Text) &&
                !string.IsNullOrEmpty(textBoxSalary.Text) &&
                !string.IsNullOrEmpty(textBoxCountHour.Text) &&
                listBoxUnits.SelectedIndex != -1)
            {
                Filiation filial = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
                Unit      unit   = filial.Units.Find(x => x.Name.Contains(listBoxUnits.SelectedItem.ToString()));

                if (unit.Employees.Find(x => x.EmployeeFIO.Name == textBoxName.Text &&
                                        x.EmployeeFIO.Surname == textBoxSurname.Text &&
                                        x.EmployeeFIO.Pathronymic == textBoxPathronymic.Text) != null)
                {
                    MessageBox.Show("Информация о данном сотруднике уже внесена.");
                    return;
                }



                Employee employee = new Employee();
                employee.EmployeeFIO.Name        = textBoxName.Text;
                employee.EmployeeFIO.Surname     = textBoxSurname.Text;
                employee.EmployeeFIO.Pathronymic = textBoxPathronymic.Text;
                employee.TypeSalary = comboBoxType.SelectedItem.ToString();
                employee.Salary     = decimal.Parse(textBoxSalary.Text, new NumberFormatInfo {
                    NumberDecimalSeparator = "."
                });
                employee.Time = decimal.Parse(textBoxCountHour.Text, new NumberFormatInfo {
                    NumberDecimalSeparator = "."
                });

                unit.Employees.Add(employee);
                listBoxEmployee.Items.Clear();
                ShowEmployee(unit);
            }
            else
            {
                MessageBox.Show("Выберите подразделение.");
            }
        }
Пример #11
0
        private void button_AddFiliation_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBoxNameFiliation.Text))
            {
                if (enterpriseBase.Filiations.Find(x => x.Name == textBoxNameFiliation.Text &&
                                                   x.Address == textBoxAddressFiliation.Text) != null)
                {
                    MessageBox.Show("Информация о данном филиале уже внесена.");
                    return;
                }

                Filiation filiation = new Filiation();
                filiation.Name    = textBoxNameFiliation.Text;
                filiation.Address = textBoxAddressFiliation.Text;

                enterpriseBase.Filiations.Add(filiation);
                ShowFiliations();
            }
        }
Пример #12
0
        private void listBoxEmployee_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxFiliations.SelectedItem != null &&
                listBoxUnits.SelectedItem != null &&
                listBoxEmployee.SelectedItem != null)
            {
                string   fio    = listBoxEmployee.SelectedItem.ToString();
                string[] masFIO = fio.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Filiation filial   = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));
                Unit      unit     = filial.Units.Find(x => x.Name.Contains(listBoxUnits.SelectedItem.ToString()));
                Employee  employee = unit.Employees.Find(x =>
                                                         x.EmployeeFIO.Name.Contains(masFIO[0]) &&
                                                         x.EmployeeFIO.Surname.Contains(masFIO[1]) &&
                                                         x.EmployeeFIO.Pathronymic.Contains(masFIO[2])
                                                         );
                if (employee != null)
                {
                    textBoxName.Text        = employee.EmployeeFIO.Name;
                    textBoxSurname.Text     = employee.EmployeeFIO.Surname;
                    textBoxPathronymic.Text = employee.EmployeeFIO.Pathronymic;
                    textBoxSalary.Text      = employee.Salary.ToString();
                    textBoxCountHour.Text   = employee.Time.ToString();
                    if (employee.TypeSalary == "Почасовая оплата")
                    {
                        comboBoxType.SelectedIndex = 1;
                    }
                    else
                    {
                        comboBoxType.SelectedIndex = 0;
                    }
                }
            }
            else
            {
                MessageBox.Show("Выберите Филиал, Подразделение и Сотрудника(данные о котором необходимо изменить)");
            }
        }
Пример #13
0
        private void button_AddUnit_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBoxNameUnit.Text) && listBoxFiliations.SelectedIndex != -1)
            {
                Filiation filiation = enterpriseBase.Filiations.Find(x => x.Name.Contains(listBoxFiliations.SelectedItem.ToString()));

                if (filiation.Units.Find(x => x.Name == textBoxNameUnit.Text) != null)
                {
                    MessageBox.Show("Информация о данном подразделении уже внесена.");
                    return;
                }

                Unit unit = new Unit();
                unit.Name      = textBoxNameUnit.Text;
                unit.Filiation = filiation;
                unit.Filiation.Units.Add(unit);

                ShowUnits(unit.Filiation);
            }
            else
            {
                MessageBox.Show("Необходимо выбрать филиал и заполнить поле Наименование.");
            }
        }
Пример #14
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFile = new OpenFileDialog();
                openFile.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                if (openFile.ShowDialog() == DialogResult.OK)
                {
                    XDocument doc = XDocument.Load(openFile.FileName);
                    if (doc.Declaration.Encoding.Equals("utf-8") || doc.Declaration.Encoding.Equals("UTF-8"))
                    {
                        saveToolStripMenuItem.Enabled = true;

                        XElement enterprise = doc.Root;
                        enterpriseBase = new Enterprise();
                        this.Text      = enterprise.Attribute("Наименование").Value;
                        if (enterprise.HasElements)
                        {
                            foreach (XElement xEnterprise in enterprise.Elements())
                            {
                                Filiation filiation = new Filiation();
                                filiation.Name    = xEnterprise.Attribute("Наименование").Value;
                                filiation.Address = xEnterprise.Attribute("Адрес").Value;

                                foreach (XElement xUnit in xEnterprise.Elements())
                                {
                                    Unit unit = new Unit();
                                    unit.Name      = xUnit.Attribute("Наименование").Value;
                                    unit.Filiation = filiation;

                                    foreach (XElement xEmployee in xUnit.Elements())
                                    {
                                        Employee employee = new Employee();
                                        employee.EmployeeFIO.Name        = xEmployee.Attribute("Имя").Value;
                                        employee.EmployeeFIO.Surname     = xEmployee.Attribute("Фамилия").Value;
                                        employee.EmployeeFIO.Pathronymic = xEmployee.Attribute("Отчество").Value;
                                        employee.TypeSalary = xEmployee.Attribute("ТипЗП").Value;;
                                        employee.Salary     = decimal.Parse(xEmployee.Attribute("ЗП").Value, new NumberFormatInfo {
                                            NumberDecimalSeparator = "."
                                        });
                                        employee.Time = decimal.Parse(xEmployee.Attribute("Часы").Value, new NumberFormatInfo {
                                            NumberDecimalSeparator = "."
                                        });
                                        employee.Unit = unit;
                                        unit.Employees.Add(employee);
                                    }
                                    filiation.Units.Add(unit);
                                }
                                enterpriseBase.Filiations.Add(filiation);
                            }
                            ShowFiliations();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Загружаемая база повреждена");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Загружаемая база повреждена");
            }
        }