コード例 #1
0
ファイル: Administrator.cs プロジェクト: injeetender/SQLSure
        private void Role_CheckedChanged(object sender, EventArgs e)
        {
            string RoleName        = string.Empty;
            string RoleFunction    = string.Empty;
            string CurBox          = string.Empty;
            string AddRemoveAction = string.Empty;

            if (Loading)
            {
                return;
            }

            try
            {
                RoleFunction = ((CheckBox)sender).Tag.ToString();
                CurBox       = ((CheckBox)sender).Name.ToString();

                if (((CheckBox)sender).Checked)
                {
                    AddRemoveAction = "Add";
                }
                else
                {
                    AddRemoveAction = "Remove";
                }

                if (CurBox.Contains("cDev"))
                {
                    RoleName = "Developer";
                }

                if (CurBox.Contains("cUAT"))
                {
                    RoleName = "Releaser UAT";
                }

                if (CurBox.Contains("cPreProd"))
                {
                    RoleName = "Releaser Pre-Production";
                }

                if (CurBox.Contains("cProd"))
                {
                    RoleName = "Releaser Production";
                }

                if (CurBox.Contains("cAdmin"))
                {
                    RoleName = "Administrator";
                }

                if (CurBox.Contains("cApproverTesting"))
                {
                    RoleName = "Testing Approver";
                }

                if (CurBox.Contains("cApproverFinal"))
                {
                    RoleName = "Final Approver";
                }

                using (DataStuff sn = new DataStuff())
                {
                    if (!sn.SaveRoleSetting(RoleName, RoleFunction, AddRemoveAction))
                    {
                        MessageBox.Show("There was an error updating the system role.", "Role Definition", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }

            catch
            {
            }
        }