Exemplo n.º 1
0
        protected EmployerHour loadHourEmployer(XmlNode xNode)
        {
            EmployerHour employer = new EmployerHour();

            employer.HourInMonth = Convert.ToDecimal(xNode.SelectSingleNode("Почасовая").InnerText);
            employer.PayPerHour  = Convert.ToDecimal(xNode.SelectSingleNode("Месячная").InnerText);
            employer.Type        = TypePayment.HourPay;


            return(employer);
        }
Exemplo n.º 2
0
        private void saveHourEmployer(XmlDocument xDoc, EmployerHour employer)
        {
            XmlNode xHourInMonth = xDoc.CreateElement("Проработанные_часы");
            XmlNode xPayPerHout  = xDoc.CreateElement("Почасовая");

            xHourInMonth.InnerText = employer.HourInMonth.ToString();
            xPayPerHout.InnerText  = employer.HourInMonth.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(xHourInMonth);
            xTop.AppendChild(xPayPerHout);
            xDoc.DocumentElement.AppendChild(xTop);
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
                }
            }
        }