コード例 #1
0
ファイル: Form1.cs プロジェクト: zhonglin94/Accounts
 private void CurrencyComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (CurrencyComboBox.ValidateEmpty())
     {
         CurrencyComboBox.BackColor = System.Drawing.Color.White;
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zhonglin94/Accounts
        private bool ValidateUserInputs()
        {
            int failedCount = 0;

            if (!NameTextBox.ValidateEmpty())
            {
                NameTextBox.BackColor = Color.OrangeRed;
                failedCount++;
            }
            if (!NameTextBox.ValidateUniqeName())
            {
                MessageBox.Show("Fail to add as the name alread exists");
                NameTextBox.BackColor = Color.OrangeRed;
                failedCount++;
            }

            if (!AmountTextBox.ValidateEmpty())
            {
                AmountTextBox.BackColor = Color.OrangeRed;
                failedCount++;
            }

            if (!AmountTextBox.ValidatePositiveNumber())
            {
                MessageBox.Show("The amount should be positive");
                AmountTextBox.BackColor = Color.OrangeRed;
                failedCount++;
            }

            if (!CategoryComboBox.ValidateEmpty())
            {
                CategoryComboBox.BackColor = Color.OrangeRed;
                failedCount++;
            }
            if (!CurrencyComboBox.ValidateEmpty())
            {
                CurrencyComboBox.BackColor = Color.OrangeRed;
                failedCount++;
            }
            if (!OccuredTimePicker.ValidateEmpty())
            {
                OccuredTimePicker.BackColor = Color.OrangeRed;
                OccuredTimePicker.Focus();
                failedCount++;
            }
            if (failedCount > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }