public void InitPermision() { string pwd = ""; string pme = ""; string pmo = ""; xmlDb.GetAccountInfo(ref pwd, ref pme, ref pmo); try { pme = crypt.DecryptDES(pme, keyStr); pmo = crypt.DecryptDES(pmo, keyStr); UInt32 pmePermission = Convert.ToUInt32(pme); UInt32 pmoPermission = Convert.ToUInt32(pmo); if ((pmePermission & PermitionItems.CheckingCodeMask) == PermitionItems.CheckingCode) { AccountPermision ap = new AccountPermision(); ap.accountType = AccountType.Developer; ap.permition = pmePermission; sysParam.UpdateAccountPermission(ap); } if ((pmoPermission & PermitionItems.CheckingCodeMask) == PermitionItems.CheckingCode) { AccountPermision ap = new AccountPermision(); ap.accountType = AccountType.Operator; ap.permition = pmoPermission; sysParam.UpdateAccountPermission(ap); } } catch { } }
private void buttonOK_Click(object sender, EventArgs e) { string pwdString = ""; // Check original admin pwd if (checkBoxModifyPwd.Checked) { if (textBoxOriginal.Text == "" && sysParam.PwdList.Count != 0) { MessageBox.Show("请输入原管理员密码!", "提示"); return; } // Check new admin pwd if (textBoxAdmin.Text == "") { MessageBox.Show("请输入管理员密码!", "提示"); return; } if (textBoxAdmin.Text != textBoxAdminConfirm.Text) { MessageBox.Show("管理员密码错误,请重输!", "提示"); textBoxAdminConfirm.Text = ""; textBoxAdmin.Text = ""; return; } // check developer pwd if (textBoxDeveloper.Text == "") { MessageBox.Show("请输入工程师密码!", "提示"); return; } if (textBoxDeveloper.Text != textBoxDeveloperConfirm.Text) { MessageBox.Show("工程师密码错误,请重输!", "提示"); textBoxDeveloper.Text = ""; textBoxDeveloperConfirm.Text = ""; return; } // check operator pwd if (textBoxOperator.Text == "") { MessageBox.Show("请输入操作员密码!", "提示"); return; } if (textBoxOperator.Text != textBoxOperatorConfirm.Text) { MessageBox.Show("操作员密码错误,请重输!", "提示"); textBoxOperator.Text = ""; textBoxOperatorConfirm.Text = ""; return; } // check if the original pwd is valid if (sysParam.PwdList.Count > 0 && textBoxOriginal.Text != sysParam.PwdList[0]) { MessageBox.Show("原管理员密码错误!", "错误"); textBoxOriginal.Text = ""; return; } pwdString = textBoxAdmin.Text + "\n" + textBoxDeveloper.Text + "\n" + textBoxOperator.Text; } // Dev Permision UInt32 permission = PermitionItems.CheckingCode; permission |= checkBoxDevParamSetting.Checked ? PermitionItems.paramSetting : 0x0; permission |= checkBoxDevPressKey.Checked ? PermitionItems.pressButton : 0x0; permission |= checkBoxDevAdjustColloid.Checked ? PermitionItems.adjustColloid : 0x0; permission |= checkBoxDevDebug.Checked ? PermitionItems.debug : 0x0; permission |= checkBoxDevDebugInfo.Checked ? PermitionItems.debugInfo : 0x0; permission |= checkBoxDevFileManager.Checked ? PermitionItems.fileManager : 0x0; permission |= checkBoxDevAccountManager.Checked ? PermitionItems.accountManager : 0x0; permission |= checkBoxDevNewPrdBat.Checked ? PermitionItems.newProductBat : 0x0; permission |= checkBoxDevSystem.Checked ? PermitionItems.systemInfo : 0x0; permission |= checkBoxDevRegister.Checked ? PermitionItems.register : 0x0; string PME = permission.ToString(); AccountPermision ap = new AccountPermision(); ap.accountType = AccountType.Developer; ap.permition = permission; sysParam.UpdateAccountPermission(ap); permission = PermitionItems.CheckingCode; permission |= checkBoxOpParamSetting.Checked ? PermitionItems.paramSetting : 0x0; permission |= checkBoxOpPressKey.Checked ? PermitionItems.pressButton : 0x0; permission |= checkBoxOpAdjustColloid.Checked ? PermitionItems.adjustColloid : 0x0; permission |= checkBoxOpDebug.Checked ? PermitionItems.debug : 0x0; permission |= checkBoxOpDebugInfo.Checked ? PermitionItems.debugInfo : 0x0; permission |= checkBoxOpFileManager.Checked ? PermitionItems.fileManager : 0x0; permission |= checkBoxOpAccountManager.Checked ? PermitionItems.accountManager : 0x0; permission |= checkBoxOpNewPrdBat.Checked ? PermitionItems.newProductBat : 0x0; permission |= checkBoxOpSystem.Checked ? PermitionItems.systemInfo : 0x0; permission |= checkBoxOpRegister.Checked ? PermitionItems.register : 0x0; string PMO = permission.ToString(); ap.accountType = AccountType.Operator; ap.permition = permission; sysParam.UpdateAccountPermission(ap); //UpdatePermission if (checkBoxModifyPwd.Checked) { xmlDb.UpdatePwd(crypt.EncryptDES(pwdString, keyStr), crypt.EncryptDES(PME, keyStr), crypt.EncryptDES(PMO, keyStr)); } else { xmlDb.UpdatePermission(crypt.EncryptDES(PME, keyStr), crypt.EncryptDES(PMO, keyStr)); } DialogResult = DialogResult.OK; Close(); }