Esempio n. 1
0
        private async void createButton_Click(object sender, EventArgs e)                               // This method run when createButton clicked
        {
            logCreate.Visible = true;                                                                   // Visiable log
            logCreate.Text    = "Checking for empty gaps";                                              // inform user about current operation
            int asyncControl = await checkForSomeEmptyGaps();                                           // Seting asyncControl variable value as a value returned by async method checkForSomeEmptyGaps

            if (asyncControl == 0)                                                                      // If asyncControl value is 0
            {
                logCreate.Visible = false;                                                              // Unvisiable log
                MessageBox.Show(appErrors.emptyGap(), appErrors.textError(),                            // Inform user about some empty gaps
                                MessageBoxButtons.OK, MessageBoxIcon.Error);                            // Set buttons and icon for messagebox
                return;                                                                                 // Stoping create code
            }
            else                                                                                        // Else
            {
                logCreate.Text = "Checking for some replaced char codes";                               // inform user about current operation
                asyncControl   = await checkForSomeReplaceCode();                                       // Seting asyncControl variable value as a value returned by async method checkForSomeReplaceCode

                if (asyncControl == 0)                                                                  // If asyncControl value is 0
                {
                    logCreate.Visible = false;                                                          // Unvisiable log
                    MessageBox.Show(appErrors.codeReplace(), appErrors.textError(),                     // Inform user about same code given two times
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);                        // Set buttons and icon for messagebox
                    return;                                                                             // Stoping create code
                }
                else                                                                                    // Else
                {
                    logCreate.Text = "Inserting new code to database";                                  // Inform user about current operation
                    asyncControl   = await insertNewCode();                                             // Seting asyncControl variable value as a value returned by async method insertNewCode

                    if (asyncControl == 0)                                                              // If asyncControl value is 0
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.noInternet(), appErrors.webError(),                   // Inform user about no internet connection
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 1)                                                         // If asyncControl value is 1
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.databaseFail(), appErrors.databaseError(),            // Inform user about some error while working in database
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 2)                                                         // If asyncControl value is 2
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.codeExist(), appErrors.databaseError(),               // Inform user about code with given name already exist
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 3)                                                         // If asyncControl value is 3
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.insertFail(), appErrors.databaseError(),              // Inform user about some error while inserting new code
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 4)                                                         // If asyncControl value is 4
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appInfos.insertingFine(), appInfos.everythingFine(),            // Inform user about successfull operation
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);              // Set buttons and icon for messagebox)
                    }
                }
            }
        }