Exemplo n.º 1
0
        private void AddPost()
        {
            if (IsValidateAdd())
            {
                string nameOfCompany = comboBoxNameOfCompany.SelectedItem.ToString();
                string typeOfPost    = comboBoxTypeOfPost.SelectedItem.ToString();
                var    post          = _qt.GetDirectoryPostEqualDates(dateTimePickerDate.Value, textBoxNameOfPost.Text, nameOfCompany);

                if (post == null)
                {
                    post = new DirectoryPost
                    {
                        Name                 = textBoxNameOfPost.Text,
                        DirectoryCompany     = _qt.GetDirectoryCompany(nameOfCompany),
                        DirectoryTypeOfPost  = _qt.GetDirectoryTypeOfPost(typeOfPost),
                        Date                 = dateTimePickerDate.Value,
                        UserWorkerSalary     = double.Parse(textBoxWorkerSalary.Text.Replace(".", ",")),
                        UserHalfWorkerSalary = double.Parse(textBoxHalfWorkerSalary.Text.Replace(".", ","))
                    };
                    _qt.AddDirectoryPost(post);
                }
                else
                {
                    post.Name                 = textBoxNameOfPost.Text;
                    post.DirectoryCompany     = _qt.GetDirectoryCompany(nameOfCompany);
                    post.DirectoryTypeOfPost  = _qt.GetDirectoryTypeOfPost(typeOfPost);
                    post.Date                 = dateTimePickerDate.Value;
                    post.UserWorkerSalary     = double.Parse(textBoxWorkerSalary.Text.Replace(".", ","));
                    post.UserHalfWorkerSalary = double.Parse(textBoxHalfWorkerSalary.Text.Replace(".", ","));
                }

                _qt.Save();

                FormFill();
            }
        }
Exemplo n.º 2
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            if (dataGridViewNameOfCompanies.SelectedRows.Count > 0)
            {
                int id = int.Parse(dataGridViewNameOfCompanies.SelectedRows[0].Cells[0].Value.ToString());
                var directoryCompany = _qt.GetDirectoryCompany(id);

                if (IsValidateRemove(directoryCompany))
                {
                    _qt.RemoveDirectoryCompany(directoryCompany);

                    _qt.Save();

                    FormFill();
                }
            }
        }