private void ButtonSave_OnClick(object sender, RoutedEventArgs e) { if (SpecificationRow == null) { if (TextBoxName.Text != String.Empty) { Context.Specifications.Add(new Specification() { Name = TextBoxName.Text }); Context.SaveChanges(); // Context.Dispose(); TextBoxName.Text = String.Empty; load(); } else { MessageBox.Show("Fill the data"); } } else //Edit { try { MessageBoxResult result = MessageBox.Show("Do you want Edit this Specification", "Edit", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { if (TextBoxName.Text != String.Empty) { SpecificationRow.Name = TextBoxName.Text; Context.SaveChanges(); SpecificationRow = null; TextBoxName.Text = String.Empty; //dispose load(); } else { MessageBox.Show("Fill the data"); } } else if (result == MessageBoxResult.Cancel) { SpecificationRow = null; TextBoxName.Text = String.Empty; } } catch (Exception exception) { SpecificationRow = null; TextBoxName.Text = String.Empty; throw; } } }
private void ButtonDelete_OnClick(object sender, RoutedEventArgs e) { try { MessageBoxResult result = MessageBox.Show("Do you want delete this Command", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { WindowDisplayCommand.DialogHostWait.IsOpen = true; WindowDisplayCommand.WrapPanelCommand.Children.Remove(this); var CommandDelete = Context.Commands.Find(ButtonDelete.CommandParameter); CommandDelete.IsDeleted = true; Context.SaveChanges(); WindowDisplayCommand.DialogHostWait.IsOpen = false; } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
private void ButtonModify_OnClick(object sender, RoutedEventArgs e) { //ADD if (UserControlCommand == null) { try { if (TextBoxQuery.Text != String.Empty && TextBoxQuery.Text != "" && TextBoxQuery.Text.Trim() != "") { DialogHostWait.IsOpen = true; UserControlCommand userControlCommand = new UserControlCommand(WindowDisplayCommand); var CommandSet = new Command() { Description = TextBoxDescription.Text, Query = TextBoxQuery.Text }; Context.Commands.Add(CommandSet); Context.SaveChanges(); Context.Dispose(); userControlCommand.ButtonDelete.CommandParameter = CommandSet.Id; userControlCommand.ButtonEdit.CommandParameter = CommandSet.Id; userControlCommand.GroupBoxCommand.Header = TextBoxDescription.Text; //string richText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd).Text; userControlCommand.RichTextBoxQuery.AppendText(TextBoxQuery.Text); WindowDisplayCommand.WrapPanelCommand.Children.Add(userControlCommand); DialogHostWait.IsOpen = false; this.Close(); } else { MessageBox.Show("يجب إدخال كورية"); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } } else //Edit { try { if (TextBoxQuery.Text != String.Empty && TextBoxQuery.Text != "" && TextBoxQuery.Text.Trim() != "") { DialogHostWait.IsOpen = true; var CommandEdit = Context.Commands.Find(UserControlCommand.ButtonEdit.CommandParameter); CommandEdit.Description = TextBoxDescription.Text; CommandEdit.Query = TextBoxQuery.Text; Context.SaveChanges(); UserControlCommand.RichTextBoxQuery.Document.Blocks.Clear(); UserControlCommand.GroupBoxCommand.Header = TextBoxDescription.Text; UserControlCommand.RichTextBoxQuery.AppendText(TextBoxQuery.Text); DialogHostWait.IsOpen = true; this.Close(); } else { MessageBox.Show("يجب إدخال كورية"); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } } }
private void ButtonAdd_OnClick(object sender, RoutedEventArgs e) { if (ComboBoxSpecification.SelectedValue != null && DatePickerDate.SelectedDate != null && TextBoxSalary.Text != string.Empty) { var JobsPostSet = new JobPost() { Date = DatePickerDate.SelectedDate.Value, Age = TextBoxAge.Text, WorkHour = TextBoxWorkHour.Text, Salary = double.Parse(TextBoxSalary.Text), Skills = TextBoxSkills.Text, Note = TextBoxNote.Text, CompanySpecificationId = (int)ComboBoxSpecification.SelectedValue }; Context.JobPosts.Add(JobsPostSet); Context.SaveChanges(); int JobPostId = JobsPostSet.Id; // fill JobPostCategory if (PickCategoriesId.Any()) { foreach (var Pick in PickCategoriesId) { Context.JobPostCategories.Add(new JobPostCategory() { CategoryId = Pick, JobPostId = JobPostId }); } Context.SaveChanges(); } // fill CompanyJobPost if (PickCompanyAreaNumJobs.Any()) { foreach (var Pick in PickCompanyAreaNumJobs) { var CompanyJobPostSet = new CompanyJobPost() { JobPostId = JobPostId, CompanyAreaId = Pick.CompanyAreaId, NumJob = Pick.NumJob }; Context.CompanyJobPosts.Add(CompanyJobPostSet); } Context.SaveChanges(); } MessageBox.Show("successful Add post"); this.Close(); } else { MessageBox.Show("Fill the miss Data"); } // this.Close(); }
private void ButtonSave_OnClick(object sender, RoutedEventArgs e) { DialogHostWait.IsOpen = true; if (ComboBoxField.SelectedValue != null && TextBoxName.Text.Trim() != String.Empty) { var CompanySet = new Company() { Name = TextBoxName.Text, Mail = TextBoxMail.Text, Phone = TextBoxPhone.Text, Address = TextBoxAddress.Text, FieldId = (int)ComboBoxField.SelectedValue, Description = TextBoxDescription.Text }; Context.Companies.Add(CompanySet); Context.SaveChanges(); // CompanySet.Id if (PickSpecificationId.Any()) { foreach (var SpecificationId in PickSpecificationId) { var CompanySpecificationSet = new CompanySpecification() { CompanyId = CompanySet.Id, SpecificationId = SpecificationId }; Context.CompanySpecifications.Add(CompanySpecificationSet); } Context.SaveChanges(); } if (PickAreaId.Any()) { foreach (var AreaId in PickAreaId) { var CompanyAreaSet = new CompanyArea() { CompanyId = CompanySet.Id, AreaId = AreaId }; Context.CompanyAreas.Add(CompanyAreaSet); } Context.SaveChanges(); } this.Close(); } else { DialogHostWait.IsOpen = false; MessageBox.Show("Fill Data"); } DialogHostWait.IsOpen = false; }