📄 gly.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace bggl.fm
{
/// <summary>
/// gly 的摘要说明。
/// </summary>
public class gly : System.Windows.Forms.Form
{
DataSet objset1=new DataSet();
cs.glysql glysql1=new bggl.cs.glysql(); //管理员cs的对象
DataSet objset2=new DataSet();
int glyid;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox comboBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public gly()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// 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.dataGrid1 = new System.Windows.Forms.DataGrid();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.comboBox1 = new System.Windows.Forms.TextBox();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.label5 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.Color.Transparent;
this.groupBox1.Controls.Add(this.dataGrid1);
this.groupBox1.Location = new System.Drawing.Point(16, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(464, 256);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "显示";
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16, 32);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(440, 216);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.DoubleClick += new System.EventHandler(this.dataGrid1_DoubleClick);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.comboBox1);
this.groupBox2.Controls.Add(this.comboBox2);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.textBox2);
this.groupBox2.Controls.Add(this.textBox1);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(16, 280);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(464, 136);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "操作";
//
// comboBox1
//
this.comboBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.comboBox1.Location = new System.Drawing.Point(104, 32);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(128, 21);
this.comboBox1.TabIndex = 11;
this.comboBox1.Text = "";
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.Items.AddRange(new object[] {
"前台",
"餐厅"});
this.comboBox2.Location = new System.Drawing.Point(320, 40);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(128, 20);
this.comboBox2.TabIndex = 10;
//
// label5
//
this.label5.BackColor = System.Drawing.Color.Transparent;
this.label5.Location = new System.Drawing.Point(240, 40);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 16);
this.label5.TabIndex = 9;
this.label5.Text = "管理员名:";
//
// textBox2
//
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox2.Location = new System.Drawing.Point(104, 94);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(128, 21);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox1.Location = new System.Drawing.Point(104, 62);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(128, 21);
this.textBox1.TabIndex = 5;
this.textBox1.Text = "";
//
// label3
//
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.Location = new System.Drawing.Point(24, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 16);
this.label3.TabIndex = 4;
this.label3.Text = "重复密码:";
//
// label2
//
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(24, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 2;
this.label2.Text = "密码:";
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(24, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 16);
this.label1.TabIndex = 0;
this.label1.Text = "管理员名:";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button4);
this.groupBox3.Controls.Add(this.button3);
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.Controls.Add(this.button1);
this.groupBox3.Location = new System.Drawing.Point(488, 16);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(120, 400);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "按钮";
//
// button4
//
this.button4.Location = new System.Drawing.Point(24, 352);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(80, 24);
this.button4.TabIndex = 9;
this.button4.Text = "退出";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(24, 312);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(80, 24);
this.button3.TabIndex = 8;
this.button3.Text = "删除";
this.button3.Click += new System.EventHandler(this.button3_Click_1);
//
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(24, 272);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 24);
this.button2.TabIndex = 7;
this.button2.Text = "修改";
this.button2.Click += new System.EventHandler(this.button2_Click_1);
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 232);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 6;
this.button1.Text = "添加";
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// gly
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(620, 426);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.Name = "gly";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "管理员管理";
this.Load += new System.EventHandler(this.gly_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void gly_Load(object sender, System.EventArgs e)
{
this.comboBox2.SelectedIndex=0;
getgly();
}
private void getgly(){
objset1=glysql1.selectexe(); //获取管理员的记录
this.dataGrid1.DataSource=objset1.Tables[0].DefaultView;
}
private void dataGrid1_DoubleClick(object sender, System.EventArgs e)
{
this.button2.Enabled=true;
int zz=this.dataGrid1.CurrentRowIndex;
if(zz!=-1)
{
glyid=Convert.ToInt32(this.dataGrid1[zz,0]);
objset1=glysql1.selectexe1(glyid);
DataRow row = objset1.Tables[0].Rows[0];
this.comboBox1.Text=row[1].ToString();
this.textBox1.Text=row[2].ToString();
this.textBox2.Text=row[2].ToString();
this.comboBox2.Text=row[3].ToString();
}
else{
MessageBox.Show("没有记录!");
this.button2.Enabled=false;
}
}
private void button4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button1_Click_1(object sender, System.EventArgs e)
{
if(this.comboBox1.Text==""||this.textBox1.Text==""||this.textBox2.Text=="")
{
MessageBox.Show("资料不完整,请填写完整");
}
else
{
if(this.textBox1.Text.Equals(this.textBox2.Text))
{
bool z=glysql1.insertexe(this.comboBox1.Text,this.textBox1.Text,this.comboBox2.Text);
if(z==true)
{
MessageBox.Show("添加成功");
getgly();
this.textBox1.Text="";
this.textBox2.Text="";
this.comboBox1.Text="";
this.comboBox2.Text="";
}
}
else
{
MessageBox.Show("两次输入的密码不正确");
}
}
}
private void button2_Click_1(object sender, System.EventArgs e)
{
this.button2.Enabled=false;
bool pd=glysql1.upexe(this.comboBox1.Text,this.textBox1.Text,this.comboBox2.Text,glyid);
if(pd==true)
{
MessageBox.Show("修改成功!");
getgly();
}
}
private void button3_Click_1(object sender, System.EventArgs e)
{
int zz=this.dataGrid1.CurrentRowIndex;
if(zz!=-1)
{
DialogResult panduan=new DialogResult();
panduan=MessageBox.Show("您确定删除当前记录吗?","确认",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(panduan==DialogResult.Yes)
{
bool pd=glysql1.delexe(this.dataGrid1[zz,0].ToString());
if(pd==true)
{
MessageBox.Show("删除成功!");
getgly();
}
}
}
else{
MessageBox.Show("没有数据可以删除!");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -