void saveButton_Click(object sender, EventArgs e) { switch (mode) { case ActionMode.NewProcess: { foreach (var item in sources) { TextBox t = item as TextBox; try { if (t.Name == "name" && !string.IsNullOrEmpty(t.Text)) { Process p = new Process() { Name = t.Text }; gujacz.CreateNewProcess(p); NoticeForm.ShowNotice("Dodano poprawnie!"); } } catch (Exception ex) { if (ex.InnerException != null) { NoticeForm.ShowNotice(ex.InnerException.Message); } else { NoticeForm.ShowNotice(ex.Message); } } } break; } case ActionMode.NewError: { int errorTypeId = -1; string description = string.Empty; string descriptionFull = string.Empty; foreach (var item in sources) { if (item is ComboBox) { errorTypeId = ((item as ComboBox).SelectedItem as Entities.ErrorType).Id; } else if (item is TextBox) { if (item.Name.Equals("description", StringComparison.CurrentCultureIgnoreCase)) { description = item.Text; } else if (item.Name.Equals("descriptionFull", StringComparison.CurrentCultureIgnoreCase)) { descriptionFull = item.Text; } } } if (errorTypeId != -1 && !string.IsNullOrEmpty(description)) { try { Entities.Error error = new Entities.Error() { ErrorTypeId = errorTypeId, Description = description, DescriptionFull = descriptionFull }; gujacz.CreateNewError(error); NoticeForm.ShowNotice("Dodano poprawnie!"); } catch (Exception ex) { if (ex.InnerException != null) { NoticeForm.ShowNotice(ex.InnerException.Message); } else { NoticeForm.ShowNotice(ex.Message); } } } else { NoticeForm.ShowNotice("Nie uzupełniono wszystkich wymaganych pól!"); } break; } case ActionMode.NewSolution: { string nameCP = string.Empty; string nameBusiness = string.Empty; foreach (var item in sources) { if (item is TextBox) { TextBox tex = item as TextBox; if (tex.Name.Equals("nameCp", StringComparison.CurrentCultureIgnoreCase)) { nameCP = tex.Text; } else if (tex.Name.Equals("nameBusiness", StringComparison.CurrentCultureIgnoreCase)) { nameBusiness = tex.Text; } } } if (!string.IsNullOrEmpty(nameCP) && !string.IsNullOrEmpty(nameBusiness)) { try { Solution solution = new Solution() { NameCP = nameCP, NameBussiness = nameBusiness }; gujacz.CreateNewSolution(solution); NoticeForm.ShowNotice("Dodano poprawnie!"); } catch (Exception ex) { if (ex.InnerException != null) { NoticeForm.ShowNotice(ex.InnerException.Message); } else { NoticeForm.ShowNotice(ex.Message); } } } else { NoticeForm.ShowNotice("Nie uzupełniono wszystkich wymaganych pól!"); } break; } case ActionMode.Bound: { int processId = -1; int errorId = -1; Process process = null; Entities.Error error = null; bool remove = false; foreach (var item in sources) { if (item is ComboBox) { ComboBox combo = item as ComboBox; if (combo.Name.Equals("processType", StringComparison.CurrentCultureIgnoreCase)) { process = (combo.SelectedItem as Process); } else if (combo.Name.Equals("errorType", StringComparison.CurrentCultureIgnoreCase)) { error = combo.SelectedItem as Entities.Error; } } else if (item is CheckBox) { remove = (item as CheckBox).Checked; } } if (process != null && error != null) { try { gujacz.BoundErrorWithProcess(process, new List <Entities.Error> { error }, remove); } catch (Exception ex) { if (ex.InnerException != null) { NoticeForm.ShowNotice(ex.InnerException.Message); } else { NoticeForm.ShowNotice(ex.Message); } } } else { NoticeForm.ShowNotice("Nie uzupełniono wszystkich wymaganych pól!"); } break; } } rbNewProcess_CheckedChanged(null, EventArgs.Empty); }
public Entities.Error CreateNewError(Entities.User user, Entities.Error error) { return(manager.HPService.CreateNewError(user, error).GetResult()); }