Beispiel #1
0
        private bool Validate_DateFormat(string text)
        {
            bool result = false;

            DateTime dt;

            try
            {
                DateTime.TryParse(text, out dt);
            }
            catch (Exception ex)
            {
                NoticeForm.ShowNotice(ex.Message);
                return(false);
            }

            if (dt.ToString() != "0001-01-01 00:00:00")
            {
                result = true;
            }

            return(result);
        }
Beispiel #2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (tbFirstName.Text != string.Empty && tbLastName.Text != string.Empty && tbSystem.SelectedItem != null && tbKategoria.SelectedItem != null && tbRodzaj.SelectedItem != null && tbTyp.SelectedItem != null && tbJiraId.Text != string.Empty)
            {
                if (!Validate_DateFormat(tbDataWystBledu.Text))
                {
                    NoticeForm.ShowNotice("Pole: Data wystąpienia błędu, zostało błędnie uzupełnione. Należy poprawić dane.");
                    return;
                }

                cancelButton.Enabled = false;
                addButton.Enabled    = false;
                issue.issueWFS       = new BillingDTHIssueWFS()
                {
                    NumerZgloszenia                  = tbNo.Text,
                    TytulZgloszenia                  = tbTitle.Text,
                    Imie                             = tbFirstName.Text,
                    Nazwisko                         = tbLastName.Text,
                    Email                            = tbEmail.Text,
                    DataWystapieniaBledu             = tbDataWystBledu.Text,
                    DataIGodzinaUtworzeniaZgloszenia = tbDataUtworzeniaZgl.Text,
                    DataIGodzinaOstatniegoKomentarza = tbDataOstKoment.Text,
                    IdKontraktu                      = tbIdKontraktu.Text,
                    IdZamowienia                     = tbIdZamowienia.Text,
                    System                           = new Entities.Component()
                    {
                        Text = ((BillingDthLBItem)tbSystem.SelectedItem).Text, Value = ((BillingDthLBItem)tbSystem.SelectedItem).Value
                    },
                    Kategoria = new Entities.Component()
                    {
                        Text = ((BillingDthLBItem)tbKategoria.SelectedItem).Text, Value = ((BillingDthLBItem)tbKategoria.SelectedItem).Value
                    },
                    Rodzaj = new Entities.Component()
                    {
                        Text = ((BillingDthLBItem)tbRodzaj.SelectedItem).Text, Value = ((BillingDthLBItem)tbRodzaj.SelectedItem).Value
                    },
                    Typ = new Entities.Component()
                    {
                        Text = ((BillingDthLBItem)tbTyp.SelectedItem).Text, Value = ((BillingDthLBItem)tbTyp.SelectedItem).Value
                    },
                    TrescZgloszenia    = tbTrescZgloszenia.Text,
                    Priorytet          = ((BillingDthLBItem)tbPriorytet.SelectedItem).Value.ToString(),
                    JiraId             = tbJiraId.Text,
                    CzyOnCall          = (cb_CzyOncall.Checked == true ? "True" : "False"),
                    SrodowiskoProblemu = (tbSrodowiskoProblemu.Text != "" ? tbSrodowiskoProblemu.Text : "---")
                };



                List <List <string> > zgloszenie = gujacz2.ExecuteStoredProcedure("[spCheckJiraId]", new string[] { issue.issueWFS.JiraId.ToString() }, DatabaseName.SupportCP);

                /* stara obsługa
                 * if(issue.issueWFS.System.Text != "Problem")
                 *  zgloszenie = gujacz2.ExecuteStoredProcedure("[spCheckJiraId]", new string[] { issue.issueWFS.JiraId.ToString() }, DatabaseName.SupportCP);
                 * else
                 *  zgloszenie = gujacz2.ExecuteStoredProcedure("[spCheckJiraId]", new string[] { issue.issueWFS.NumerZgloszenia.ToString() }, DatabaseName.SupportCP);
                 */

                if (zgloszenie.Count > 0)
                {
                    NoticeForm nf = new NoticeForm(("Numer zgłoszenia " + issue.issueWFS.NumerZgloszenia + " istnieje już zapisany pod nr sprawy: " + zgloszenie[0][1].ToString()), NoticeButtons.OK, new string[] { "OK" });

                    nf.ShowDialog();

                    this.Close();
                }

                else
                {
                    if (_newIssue)
                    {
                        issue.issueHelios = new IssueHelios()
                        {
                            number             = tbNo.Text,
                            title              = tbTitle.Text,
                            firstName          = tbFirstName.Text,
                            lastName           = tbLastName.Text,
                            email              = tbEmail.Text,
                            date               = tbDataOstKoment.Text,
                            updated            = tbDataWystBledu.Text,
                            projekt            = ((BillingDthLBItem)tbKategoria.SelectedItem).Text,
                            rodzaj_zgloszenia  = ((BillingDthLBItem)tbSystem.SelectedItem).Text,
                            rodzaj_bledu       = ((BillingDthLBItem)tbRodzaj.SelectedItem).Text,
                            severity           = ((BillingDthLBItem)tbPriorytet.SelectedItem).Value.ToString(),
                            czyOnCall          = (cb_CzyOncall.Checked == true ? "True" : "False"),
                            srodowiskoProblemu = (tbSrodowiskoProblemu.Text != "" ? tbSrodowiskoProblemu.Text : "---")
                        };
                    }
                    if (mass && callback != null)//Jeśli dodawana masowo, to wyślij obiekt przez callback
                    {
                        callback(issue, _tr, _newIssue);
                        this.Close();
                    }
                    else
                    { // jeśli nie dodawane masowo tylko pojedyńczo to zapisz obiekt
                        doByWorker(new DoWorkEventHandler(doWorkSaveToWFS), issue, new RunWorkerCompletedEventHandler(doSavingCompleted));
                    }
                }
            }
            else
            {
                if (sender.ToString() != "autousupelnianie")
                {
                    MessageBox.Show("Przed dodaniem zgłoszenia do WFS należy uzupełnić wszystkie wymagane pola.", "Brak danych", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }
        }
Beispiel #3
0
        public static DialogResult ShowNotice(string message)
        {
            var nf = new NoticeForm(message);

            return(nf.ShowDialog());
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        public static DialogResult ShowNotice(string message, NoticeButtons buttons, string[] buttonsLabels)
        {
            var nf = new NoticeForm(message, buttons, buttonsLabels);

            return(nf.ShowDialog());
        }