frmsystemset.cs
来自「小区物业管理:管理小区的费用、小区工作人员的编排和工资管理、小区的运作、对住户资」· CS 代码 · 共 242 行
CS
242 行
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace WindowsApplication1
{
/// <summary>
/// frmsystemset 的摘要说明。
/// </summary>
public class frmsystemset : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private SqlConnection objSqlConn;
private SqlCommand objSqlCmd;
private SqlDataAdapter objSqlAdapter;
private DataSet objDataSet;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
string username;
public frmsystemset(string Uname)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
username=Uname;
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <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.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.checkBox2);
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.groupBox1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.groupBox1.Location = new System.Drawing.Point(24, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(280, 112);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "数据库选项";
//
// checkBox2
//
this.checkBox2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.checkBox2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.checkBox2.Location = new System.Drawing.Point(16, 64);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(176, 24);
this.checkBox2.TabIndex = 3;
this.checkBox2.Text = "数据库禁止改动";
//
// checkBox1
//
this.checkBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.checkBox1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.checkBox1.Location = new System.Drawing.Point(16, 24);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(176, 24);
this.checkBox1.TabIndex = 2;
this.checkBox1.Text = "数据库所有数据清零";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.radioButton2);
this.groupBox2.Controls.Add(this.radioButton1);
this.groupBox2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.groupBox2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.groupBox2.Location = new System.Drawing.Point(24, 144);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(280, 112);
this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "权限设置";
//
// radioButton2
//
this.radioButton2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.radioButton2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.radioButton2.Location = new System.Drawing.Point(16, 72);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(224, 24);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "撤消对所有管理员的权限禁止";
//
// radioButton1
//
this.radioButton1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.radioButton1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.radioButton1.Location = new System.Drawing.Point(16, 32);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(224, 24);
this.radioButton1.TabIndex = 0;
this.radioButton1.Text = "禁止非admin管理员进行改动";
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button1.Location = new System.Drawing.Point(128, 264);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 32);
this.button1.TabIndex = 5;
this.button1.Text = "提交";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button2.Location = new System.Drawing.Point(224, 264);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 32);
this.button2.TabIndex = 6;
this.button2.Text = "撤消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// frmsystemset
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 302);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(336, 336);
this.MinimumSize = new System.Drawing.Size(336, 336);
this.Name = "frmsystemset";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "系统设置";
this.Load += new System.EventHandler(this.frmsystemset_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void frmsystemset_Load(object sender, System.EventArgs e)
{
objSqlConn=new SqlConnection("database=atorregulate;user id=sa;password=;SERVER=(local)");
objSqlConn.Open();
}
private void button1_Click(object sender, System.EventArgs e)
{
if(username=="admin")
{
if(checkBox1.Checked)
{
try
{
objSqlConn=new SqlConnection("SERVER=(local);user id=sa;password=;database=atorregulate");
objSqlConn.Open();
string strcmd="delete from userfee;delete from storey;delete from worker;delete from carpark;delete from comment;delete from happening;delete from userdatrm;delete from workerearnings";
this.objSqlCmd = new SqlCommand(strcmd,this.objSqlConn);
this.objSqlCmd.ExecuteNonQuery();
MessageBox.Show("数据库所有数据成功清零!","服务器确认");
}
catch(SqlException ex)
{
MessageBox.Show(ex.ToString());
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
if(checkBox2.Checked)
{
objSqlConn=new SqlConnection("SERVER=(local);uid=sa;password=;database=atorregulate");
objSqlConn.Close();
MessageBox.Show("权限设置成功!","服务器接受");
}
}
else
MessageBox.Show("您没有设置此项的权限!","服务器拒绝");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?