Пример #1
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            // Called to make sure that all current data are stored in data row
            this.btnOK.Focus();

            if (this.WorkReport.ToTime.Subtract(this.WorkReport.FromTime).TotalMinutes == 0)
            {
                if (MessageBoxHelper.Ask("Work report has to last at least one minute. Do you want to keep on counting?") == MessageBoxResult.Yes)
                {
                    this.OnKeepCounting();
                }

                return;
            }

            if (string.IsNullOrEmpty(this.tbxSubject.Text))
            {
                MessageBoxHelper.Warn("Subject has to be specified.");
                return;
            }

            if (this.cboProject.EditValue == null)
            {
                MessageBoxHelper.Warn("Project has to be specified.");
                return;
            }

            if (this.cboType.SelectedValue == null)
            {
                MessageBoxHelper.Warn("Type has to be specified.");
                return;
            }

            this.SaveUserSettings();

            this.workReport.EndEdit();

            this.DialogResult = true;
        }
Пример #2
0
        void businessLogic_StartCountingRequested(object sender, BusinessLogic.StartCountingEventArgs e)
        {
            string message;

            switch (e.Reason)
            {
            case StartCountingReasons.AutoContinued:
                message = "Do you want to continue with counting?";
                break;

            case StartCountingReasons.SystemUnlocked:
                message = "Computer has been unlocked. Do you want to continue with counting?";
                break;

            default:
                throw new InvalidOperationException(string.Format("Unknown StartCountingReasons reason '{0}'", e.Reason));
            }

            if (MessageBoxHelper.Ask(message) == MessageBoxResult.Yes)
            {
                e.Handled = e.Continue = true;
            }
        }