예제 #1
0
        protected EmployerMonth loadMonthEmployer(XmlNode xNode)
        {
            EmployerMonth employer = new EmployerMonth();

            employer.PayPerMonth = Convert.ToDecimal(xNode.SelectSingleNode("Месячная").InnerText);
            employer.Type        = TypePayment.MonthPay;


            return(employer);
        }
예제 #2
0
        private void saveMonthEmployer(XmlDocument xDoc, EmployerMonth employer)
        {
            XmlNode xPayPerMonth = xDoc.CreateElement("Месячная");

            xPayPerMonth.InnerText = employer.PayPerMonth.ToString();

            XmlNode xTop         = xDoc.CreateElement("Человек");
            XmlNode xSurname     = xDoc.CreateElement("Фамилия");
            XmlNode xName        = xDoc.CreateElement("Имя");
            XmlNode xPatronymic  = xDoc.CreateElement("Отчество");
            XmlNode xDateBirtday = xDoc.CreateElement("Дата_рождения");
            XmlNode xType        = xDoc.CreateElement("Тип");
            XmlNode xSalary      = xDoc.CreateElement("Зарплата");

            int j = 0;

            foreach (Salary i in employer.ListSalary)
            {
                XmlNode xPay     = xDoc.CreateElement("Плата" + j);
                XmlNode xDataPay = xDoc.CreateElement("Дата_зарплаты");
                XmlNode xAmount  = xDoc.CreateElement("Количество");
                xDataPay.InnerText = i.DateSalary.ToFileTime().ToString();
                xAmount.InnerText  = i.Amount.ToString();
                xPay.AppendChild(xDataPay);
                xPay.AppendChild(xAmount);
                xSalary.AppendChild(xPay);
                j++;
            }
            xSurname.InnerText     = employer.Surname;
            xName.InnerText        = employer.Name;
            xPatronymic.InnerText  = employer.Patronymic;
            xDateBirtday.InnerText = employer.DateBirthday.ToFileTime().ToString();
            xType.InnerText        = employer.Type.ToString();
            xTop.AppendChild(xSurname);
            xTop.AppendChild(xName);
            xTop.AppendChild(xPatronymic);
            xTop.AppendChild(xDateBirtday);
            xTop.AppendChild(xType);
            xTop.AppendChild(xSalary);

            xTop.AppendChild(xPayPerMonth);
            xDoc.DocumentElement.AppendChild(xTop);
        }
예제 #3
0
        public Wage()
        {
            var d = new Database();

            d.onAdd((IEmployer employer) => {
                // добавить этих сотрудников в модель таблицы
                var it = new ListViewItem(employer.Surname);
                it.SubItems.Add(employer.Name);
                it.SubItems.Add(employer.DateBirthday.ToShortDateString());

                listViewWorkers.Items.Add(it);
            });

            d.onFlush(() => {
                listViewWorkers.Clear();
            });

            // d.loadfile("asd");
            // d.savefile("asd");


            AddOwnedForm(form2);
            form2.textBoxSurname.Validating            += textBoxSurname_Validating;
            form2.textBoxSurname.KeyPress              += textBoxSurname_KeyPress;
            form2.textBoxSurname.Enter                 += textBox_Enter;
            form2.textBoxName.Validating               += textBoxName_Validating;
            form2.textBoxName.KeyPress                 += textBoxName_KeyPress;
            form2.textBoxName.Enter                    += textBox_Enter;
            form2.textBoxPatronymic.Validating         += textBoxPatronymic_Validating;
            form2.textBoxPatronymic.KeyPress           += textBoxName_KeyPress;
            form2.textBoxPatronymic.Enter              += textBox_Enter;
            form2.radioButtonMonthlyPay.CheckedChanged += radioButtonMonthlyPayFormAdd_CheckedChanged;
            form2.radioButtonHourPay.CheckedChanged    += radioButtonHourPayFormAdd_CheckedChanged;
            form2.buttonNFAdd.Click                    += (senderSlave, eSlave) =>
            {
                if (NotEmptyFieldsFormAdd())
                {
                    if (textBoxFind.Text != "")
                    {
                        textBoxFind.Text = "";
                        return;
                    }
                    ConstructListView();
                    if (form2.radioButtonMonthlyPay.Checked)
                    {
                        var p = new EmployerMonth
                        {
                            Type         = TypePayment.MonthPay,
                            Name         = form2.textBoxName.Text,
                            Surname      = form2.textBoxSurname.Text,
                            Patronymic   = form2.textBoxPatronymic.Text,
                            DateBirthday = form2.dateTimePickerDateBirthday.Value,
                            PayPerMonth  = form2.numericUpDownPayPerMonth.Value,
                            ListSalary   = new List <Salary>(),
                        };
                        var it = new ListViewItem(p.Surname);
                        it.SubItems.Add(p.Name);
                        it.SubItems.Add(p.DateBirthday.ToShortDateString());
                        IEmployer worker  = p;
                        string    listKey = p.Surname + p.Name + p.DateBirthday.ToShortDateString();
                        try
                        {
                            IndexEmplployee.Add(listKey, worker);
                            listViewWorkers.Items.Add(it);
                            // ListEmplployee.Add(p);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Человек с такими данными уже существует.");
                        }
                    }
                    else
                    {
                        var p = new EmployerHour
                        {
                            Type         = TypePayment.HourPay,
                            Name         = form2.textBoxName.Text,
                            Surname      = form2.textBoxSurname.Text,
                            Patronymic   = form2.textBoxPatronymic.Text,
                            DateBirthday = form2.dateTimePickerDateBirthday.Value,
                            PayPerHour   = form2.numericUpDownPayPerHour.Value,
                            HourInMonth  = form2.numericUpDownHourInMonth.Value,
                            ListSalary   = new List <Salary>(),
                        };
                        var it = new ListViewItem(p.Surname);
                        it.SubItems.Add(p.Name);
                        it.SubItems.Add(p.DateBirthday.ToShortDateString());
                        IEmployer worker  = p;
                        string    listKey = p.Surname + p.Name + p.DateBirthday.ToShortDateString();
                        try
                        {
                            IndexEmplployee.Add(listKey, worker);
                            listViewWorkers.Items.Add(it);
                            // ListEmplployee.Add(p);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Человек с такими данными уже существует");
                        }
                    }
                    ClearFieldsFormAdd();
                    textBoxName.BackColor    = SystemColors.Window;
                    textBoxSurname.BackColor = SystemColors.Window;
                    form2.Hide();
                    changes = true;
                }
                else
                {
                    ColorFieldFormAdd();
                }
            };
            InitializeComponent();
        }
예제 #4
0
        /// <summary>
        /// Изменение данных сотрудника.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonChange_Click_1(object sender, EventArgs e)
        {
            if (listViewWorkers.SelectedItems.Count != 0)
            {
                if (NotEmptyFields())
                {
                    //textBoxFind.Text = "";
                    IEmployer dictonaryValue;

                    string key = listViewWorkers.SelectedItems[0].SubItems[0].Text;
                    key += listViewWorkers.SelectedItems[0].SubItems[1].Text;
                    key += listViewWorkers.SelectedItems[0].SubItems[2].Text;

                    if (IndexEmplployee.TryGetValue(key, out dictonaryValue))
                    {
                    }
                    if (radioButtonMonthlyPay.Checked)
                    {
                        var p = new EmployerMonth
                        {
                            Type         = TypePayment.MonthPay,
                            Name         = textBoxName.Text,
                            Surname      = textBoxSurname.Text,
                            Patronymic   = textBoxPatronymic.Text,
                            DateBirthday = dateTimePickerDateBirthday.Value,
                            PayPerMonth  = numericUpDownPayPerMonth.Value,
                            ListSalary   = dictonaryValue.ListSalary,
                        };
                        // ListEmplployee[ListEmplployee.IndexOf(dictonaryValue)] = p;
                        listViewWorkers.SelectedItems[0].SubItems[0].Text = p.Surname;
                        listViewWorkers.SelectedItems[0].SubItems[1].Text = p.Name;
                        listViewWorkers.SelectedItems[0].SubItems[2].Text = p.DateBirthday.ToShortDateString();

                        // IndexEmplployee.Remove(key);
                        key = p.Surname + p.Name + p.DateBirthday.ToShortDateString();
                        //IndexEmplployee.Add(key, p);
                    }
                    else
                    {
                        var p = new EmployerHour
                        {
                            Type         = TypePayment.HourPay,
                            Name         = textBoxName.Text,
                            Surname      = textBoxSurname.Text,
                            Patronymic   = textBoxPatronymic.Text,
                            DateBirthday = dateTimePickerDateBirthday.Value,
                            PayPerHour   = numericUpDownPayPerHour.Value,
                            HourInMonth  = numericUpDownHourInMonth.Value,
                            ListSalary   = dictonaryValue.ListSalary,
                        };

                        //ListEmplployee[ListEmplployee.IndexOf(dictonaryValue)] = p;
                        listViewWorkers.SelectedItems[0].SubItems[0].Text = p.Surname;
                        listViewWorkers.SelectedItems[0].SubItems[1].Text = p.Name;
                        listViewWorkers.SelectedItems[0].SubItems[2].Text = p.DateBirthday.ToShortDateString();

                        IndexEmplployee.Remove(key);
                        key = p.Surname + p.Name + p.DateBirthday.ToShortDateString();
                        IndexEmplployee.Add(key, p);
                    }
                    changes = true;
                }
                else
                {
                    ColorField();
                }
            }
        }