📄 setrulecode.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace XFMAS.Admin
{
/// <summary>
/// SetRuleCode 的摘要说明。
/// </summary>
public class SetRuleCode : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.CheckBox R_001;
private System.Windows.Forms.CheckBox R_003;
private System.Windows.Forms.CheckBox R_002;
private System.Windows.Forms.CheckBox R_004;
private System.Windows.Forms.CheckBox R_005;
private System.Windows.Forms.CheckBox allSelect;
private System.Windows.Forms.GroupBox rcs;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.CheckBox R_006;
//
public string ruleCodeStr = null;
public SetRuleCode()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
public void SetRuleCodeStr(string ruleCodeStr){
this.ruleCodeStr = ruleCodeStr;
if(this.ruleCodeStr != null && this.ruleCodeStr.IndexOf("'") > -1){
this.ruleCodeStr = this.ruleCodeStr.Replace("''","'");
string[] _rcs = ruleCodeStr.Split('\'');
for(int i=0;i<_rcs.Length;i++){
string _rc = _rcs[i];
if(!_rc.Equals(null) && _rc.IndexOf("R_") == 0){
for(int j=0;j<this.rcs.Controls.Count;j++){
if(((CheckBox)this.rcs.Controls[j]).Name.ToUpper() == _rc.ToUpper()){
((CheckBox)this.rcs.Controls[j]).Checked = true;
}
}
}
}
}
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.rcs = new System.Windows.Forms.GroupBox();
this.R_005 = new System.Windows.Forms.CheckBox();
this.R_004 = new System.Windows.Forms.CheckBox();
this.R_002 = new System.Windows.Forms.CheckBox();
this.R_003 = new System.Windows.Forms.CheckBox();
this.R_001 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.allSelect = new System.Windows.Forms.CheckBox();
this.R_006 = new System.Windows.Forms.CheckBox();
this.rcs.SuspendLayout();
this.SuspendLayout();
//
// rcs
//
this.rcs.Controls.Add(this.R_006);
this.rcs.Controls.Add(this.R_005);
this.rcs.Controls.Add(this.R_004);
this.rcs.Controls.Add(this.R_002);
this.rcs.Controls.Add(this.R_003);
this.rcs.Controls.Add(this.R_001);
this.rcs.Location = new System.Drawing.Point(8, 16);
this.rcs.Name = "rcs";
this.rcs.Size = new System.Drawing.Size(280, 240);
this.rcs.TabIndex = 0;
this.rcs.TabStop = false;
this.rcs.Text = "系统权限";
//
// R_005
//
this.R_005.Location = new System.Drawing.Point(24, 160);
this.R_005.Name = "R_005";
this.R_005.Size = new System.Drawing.Size(224, 24);
this.R_005.TabIndex = 4;
this.R_005.Text = "注册内网用户名/IP地址到服务器";
this.R_005.CheckedChanged += new System.EventHandler(this.R_005_CheckedChanged);
//
// R_004
//
this.R_004.Location = new System.Drawing.Point(24, 128);
this.R_004.Name = "R_004";
this.R_004.Size = new System.Drawing.Size(160, 24);
this.R_004.TabIndex = 3;
this.R_004.Text = "提醒时间设置";
this.R_004.CheckedChanged += new System.EventHandler(this.R_004_CheckedChanged);
//
// R_002
//
this.R_002.Location = new System.Drawing.Point(24, 96);
this.R_002.Name = "R_002";
this.R_002.Size = new System.Drawing.Size(160, 24);
this.R_002.TabIndex = 2;
this.R_002.Text = "设置管理及其权限";
this.R_002.CheckedChanged += new System.EventHandler(this.R_002_CheckedChanged);
//
// R_003
//
this.R_003.Location = new System.Drawing.Point(24, 64);
this.R_003.Name = "R_003";
this.R_003.Size = new System.Drawing.Size(160, 24);
this.R_003.TabIndex = 1;
this.R_003.Text = "查看/管理用户";
this.R_003.CheckedChanged += new System.EventHandler(this.R_003_CheckedChanged);
//
// R_001
//
this.R_001.Location = new System.Drawing.Point(24, 32);
this.R_001.Name = "R_001";
this.R_001.Size = new System.Drawing.Size(160, 24);
this.R_001.TabIndex = 0;
this.R_001.Text = "查看就餐数据";
this.R_001.CheckedChanged += new System.EventHandler(this.R_001_CheckedChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(160, 272);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 23);
this.button1.TabIndex = 1;
this.button1.Text = "确 认";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(224, 272);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 23);
this.button2.TabIndex = 2;
this.button2.Text = "取 消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// allSelect
//
this.allSelect.Location = new System.Drawing.Point(8, 272);
this.allSelect.Name = "allSelect";
this.allSelect.Size = new System.Drawing.Size(112, 24);
this.allSelect.TabIndex = 4;
this.allSelect.Text = "全选";
this.allSelect.CheckedChanged += new System.EventHandler(this.allSelect_CheckedChanged);
//
// R_006
//
this.R_006.Location = new System.Drawing.Point(24, 192);
this.R_006.Name = "R_006";
this.R_006.Size = new System.Drawing.Size(144, 24);
this.R_006.TabIndex = 5;
this.R_006.Text = "修改用户就餐数据";
//
// SetRuleCode
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(298, 311);
this.Controls.Add(this.allSelect);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.rcs);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SetRuleCode";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "设置管理员权限";
this.rcs.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 全选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void allSelect_CheckedChanged(object sender, System.EventArgs e) {
if(this.allSelect.Text == "全选"){
this.allSelect.Text = "全不选";
for(int i=0;i<this.rcs.Controls.Count;i++){
((CheckBox)this.rcs.Controls[i]).Checked = true;
}
}else{
this.allSelect.Text = "全选";
for(int i=0;i<this.rcs.Controls.Count;i++){
((CheckBox)this.rcs.Controls[i]).Checked = false;
}
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void R_001_CheckedChanged(object sender, System.EventArgs e) {
this.CheckAllSelect();
}
/// <summary>
/// 是否全选
/// </summary>
private void CheckAllSelect(){
/*
bool isAll = true;
for(int i=0;i<this.rcs.Controls.Count;i++){
if(!((CheckBox)this.rcs.Controls[i]).Checked){
isAll = false;
}
}
if(isAll && !this.allSelect.Checked){
this.allSelect.Checked = true;
}else{
this.allSelect.Checked = isAll;
}*/
}
private void R_003_CheckedChanged(object sender, System.EventArgs e) {
this.CheckAllSelect();
}
private void R_002_CheckedChanged(object sender, System.EventArgs e) {
this.CheckAllSelect();
}
private void R_004_CheckedChanged(object sender, System.EventArgs e) {
this.CheckAllSelect();
}
private void R_005_CheckedChanged(object sender, System.EventArgs e) {
this.CheckAllSelect();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, System.EventArgs e) {
this.ruleCodeStr = "";
for(int i=0;i<this.rcs.Controls.Count;i++){
if(((CheckBox)this.rcs.Controls[i]).Checked){
this.ruleCodeStr += "'"+ ((CheckBox)this.rcs.Controls[i]).Name +"'";
}
}
this.Close();
}
private void button2_Click(object sender, System.EventArgs e) {
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -