コード例 #1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != ""
                )
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            int newerDays = PIn.Int(textDays.Text);

            if (newerDays > 3000)
            {
                MsgBox.Show(this, "Days must be less than 3000.");
                return;
            }
            Cur.NewerDays = newerDays;
            Cur.NewerDate = PIn.Date(textDate.Text);
            try{
                if (Cur.IsNew)
                {
                    GroupPermissions.Insert(Cur);
                }
                else
                {
                    GroupPermissions.Update(Cur);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            DialogResult = DialogResult.OK;
        }
コード例 #2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != "" || textDays.errorProvider1.GetError(textDays) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            int newerDays = PIn.Int(textDays.Text);

            if (newerDays > GroupPermissions.NewerDaysMax)
            {
                MsgBox.Show(this, $"Days must be less than {GroupPermissions.NewerDaysMax.ToString()}.");
                return;
            }
            Cur.NewerDays = newerDays;
            Cur.NewerDate = PIn.Date(textDate.Text);
            try{
                if (Cur.IsNew)
                {
                    GroupPermissions.Insert(Cur);
                }
                else
                {
                    GroupPermissions.Update(Cur);
                }
                SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, 0, $"Permission '{Cur.PermType}' granted to " +
                                          $"'{UserGroups.GetGroup(Cur.UserGroupNum).Description}'");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            DialogResult = DialogResult.OK;
        }