コード例 #1
0
 /// <summary>
 /// AddEdit button click event; adds or edits an value for a supplier or product
 /// </summary>
 /// <param name="sender">event parameter</param>
 /// <param name="e">event parameter</param>
 private void addEditButton_Click(object sender, EventArgs e)
 {
     try
     {
         // Check that a value was entered
         if (!Validation.IsNotEmptyOrNull(addEditTextBox))
         {
             TawicoMessageBox messageBox = new TawicoMessageBox();
             messageBox.Text = "Error";
             String message = "Please enter a value before submitting.";
             messageBox.Show(message, Color.Black);
         }
         else
         {
             DialogResult = DialogResult.OK;// Text was entered into the field, accept the result
         }
     }
     catch (Exception ex)
     {
         //create custom message box instance
         //show message box
         TawicoMessageBox showMessageBox = new TawicoMessageBox();
         showMessageBox.Text = ex.GetType().Name;
         showMessageBox.Show(ex.Message, Color.Black);
         //MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 /// <summary>
 /// Processes add and save requests
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void addSaveButton_Click(object sender, EventArgs e)
 {
     try
     {
         // If the form is valid, set all public properties to the values in the form
         if (isValidForm())
         {
             PackageName             = nameTextBox.Text.Trim();
             PartnerURL              = partnerURLTextBox.Text.Trim();
             PackageStartDate        = startDateTimePicker.Value;
             PackageEndDate          = endDateTimePicker.Value;
             PackageBasePrice        = decimal.Parse(basePriceTextBox.Text.Trim());
             PackageAgencyCommission = decimal.Parse(agencyCommissionTextBox.Text.Trim());
             AirfairInclusion        = airfairInclusionCheckBox.Checked;
             PackageDescription      = descriptionTextBox.Text.Trim();
             DialogResult            = DialogResult.OK;
         }
     }
     catch (Exception ex)
     {
         //create custom message box instance
         //show message box
         TawicoMessageBox showMessageBox = new TawicoMessageBox();
         showMessageBox.Text = ex.GetType().Name;
         showMessageBox.Show(ex.Message, Color.Black);
         //MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
        /// <summary>
        /// Checks if form is valid. If its invalid, show a messagebox with error.
        /// </summary>
        /// <returns>Form valid?</returns>
        private bool isValidForm()
        {
            String message = ""; // Empty string

            // Goes through validation and adds message to string
            if (!isValidPackageName)
            {
                message += "Must enter a package name.\n";
            }
            if (!isValidImage)
            {
                message += "Must select a path for the image.\n";
            }
            if (!isValidPartnerURL)
            {
                message += "Must enter a partner url.\n";
            }
            if (!isValidPackageDates)
            {
                message += "Start date must be before end date.\n";
            }
            if (!isValidDescription)
            {
                message += "Must enter a description.\n";
            }
            if (!isValidPackageBasePrice)
            {
                message += "Must enter a base price.\n";
            }
            if (!isValidPackageAgencyCommission && agencyCommissionTextBox.Text.Trim() == "")
            {
                message += "Must enter an agency commission.\n";
            }
            else if (!isValidPackageAgencyCommission)
            {
                message += "Agency commission must be less than base price.\n";
            }

            // If string is empty, all validation passed. Show error message otherwise.
            if (message != "")
            {
                //create custom message box instance
                //show message box
                TawicoMessageBox showMessageBox = new TawicoMessageBox();
                showMessageBox.Text = "Form Error";
                showMessageBox.Show(message, Color.Black);
                //MessageBox.Show(message, "Form Error");
                return(false);
            }
            else
            {
                return(true);
            }
        }