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(); } }
private void buttonRemove_Click(object sender, EventArgs e) { if (listBoxTypeOfPosts.SelectedIndex != -1) { string typeOfPost = listBoxTypeOfPosts.SelectedItem.ToString(); var directoryTypeOfPost = _qt.GetDirectoryTypeOfPost(typeOfPost); if (IsValidateRemove(directoryTypeOfPost)) { _qt.RemoveDirectoryTypeOfPost(directoryTypeOfPost); _qt.Save(); FormFill(); } } }