コード例 #1
0
ファイル: OptionsForm.cs プロジェクト: ethan-hann/TimeTracker
        private void btnClear_Click(object sender, EventArgs e)
        {
            DialogResult result = CMessageBox.Show("This will clear all values (including save path)!\nAre you sure?", "Confirm", MessageBoxButtons.YesNo, Resources.info_32);

            if (result == DialogResult.Yes)
            {
                txtFullName.Text             = "";
                txtHourlyRate.Text           = "";
                txtOvertimeRate.Text         = "";
                txtBillableRate.Text         = "";
                chkDefaultOvertime.Checked   = false;
                lblLocation.Values.ExtraText = "";

                name         = "";
                hourlyRate   = 0.0M;
                overtimeRate = 0.0M;
                billableRate = 0.0M;
                savePath     = "";

                SaveSettings();
            }
        }
コード例 #2
0
ファイル: OptionsForm.cs プロジェクト: ethan-hann/TimeTracker
        private bool ValidateFields()
        {
            bool valid = false;

            if (txtFullName.Text.Length > 0)
            {
                valid = true;
            }
            else
            {
                CMessageBox.Show("You must enter a name to appear\non the timesheet.", "No name entered", MessageBoxButtons.OK, Resources.warning_32);
                valid = false;
                return(valid);
            }

            if (decimal.TryParse(txtHourlyRate.Text, out decimal h))
            {
                hourlyRate = h;
                valid      = true;
            }
            else
            {
                CMessageBox.Show("The hourly rate entered was not in decimal format.", "Invalid format", MessageBoxButtons.OK, Resources.warning_32);
                valid = false;
                return(valid);
            }

            if (decimal.TryParse(txtOvertimeRate.Text, out decimal o))
            {
                overtimeRate = o;
                valid        = true;
            }
            else
            {
                CMessageBox.Show("The overtime rate entered was not in decimal format.", "Invalid format", MessageBoxButtons.OK, Resources.warning_32);
                valid = false;
                return(valid);
            }

            if (decimal.TryParse(txtBillableRate.Text, out decimal b))
            {
                billableRate = b;
                valid        = true;
            }
            else
            {
                CMessageBox.Show("The billable rate entered was not in decimal format.", "Invalid format", MessageBoxButtons.OK, Resources.warning_32);
                valid = false;
                return(valid);
            }

            if (savePath.Length > 0)
            {
                valid = true;
            }
            else
            {
                CMessageBox.Show("No path specified for timesheet file.", "Invalid path", MessageBoxButtons.OK, Resources.warning_32);
                valid = false;
                return(valid);
            }

            return(valid);
        }