⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form5.cs

📁 只做了一部分,希望以后能向各位高手学习,好学就是我咯!
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.button4.Location = new System.Drawing.Point(16, 48);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(72, 24);
			this.button4.TabIndex = 11;
			this.button4.Text = "添加用户";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// button3
			// 
			this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.button3.Location = new System.Drawing.Point(16, 16);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(72, 24);
			this.button3.TabIndex = 10;
			this.button3.Text = "修改用户";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// pictureBox2
			// 
			this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
			this.pictureBox2.Location = new System.Drawing.Point(104, 8);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(8, 176);
			this.pictureBox2.TabIndex = 9;
			this.pictureBox2.TabStop = false;
			// 
			// textBox3
			// 
			this.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox3.Location = new System.Drawing.Point(232, 104);
			this.textBox3.Name = "textBox3";
			this.textBox3.PasswordChar = '*';
			this.textBox3.Size = new System.Drawing.Size(152, 21);
			this.textBox3.TabIndex = 7;
			this.textBox3.Text = "";
			this.textBox3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			this.textBox3.Visible = false;
			// 
			// textBox2
			// 
			this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox2.Location = new System.Drawing.Point(232, 72);
			this.textBox2.Name = "textBox2";
			this.textBox2.PasswordChar = '*';
			this.textBox2.Size = new System.Drawing.Size(152, 21);
			this.textBox2.TabIndex = 6;
			this.textBox2.Text = "";
			this.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			// 
			// textBox1
			// 
			this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox1.Location = new System.Drawing.Point(232, 40);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(152, 21);
			this.textBox1.TabIndex = 5;
			this.textBox1.Text = "";
			this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(128, 136);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(88, 24);
			this.label5.TabIndex = 4;
			this.label5.Text = "用户类型";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(128, 40);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(88, 24);
			this.label4.TabIndex = 3;
			this.label4.Text = "用户名字";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(128, 104);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(88, 24);
			this.label3.TabIndex = 2;
			this.label3.Text = "确认密码";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			this.label3.Visible = false;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(128, 72);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(88, 24);
			this.label2.TabIndex = 1;
			this.label2.Text = "用户密码";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// Form5
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(440, 342);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.pictureBox1);
			this.Name = "Form5";
			this.Text = "用户相关";
			this.Load += new System.EventHandler(this.Form5_Load);
			this.groupBox1.ResumeLayout(false);
			this.tabControl1.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.tabPage2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		public lzlMain lin
		{
			get 
			{ 
				return lzl; 
			}
			set
			{
				lzl = value;
			}
		}

		#region 全局变量
		int num=0;
		#endregion 
		
		private void button1_Click(object sender, System.EventArgs e)
		{
			searchall a=new searchall();
			a.search("select id as 用户编号,name as 名字,user_type as 用户类型 from enter",this.dataGrid1);
			/*DataConn dc=new DataConn();
			string str=dc.connstr ;
			SqlConnection conn=new SqlConnection (str);
			DataSet dataset=new DataSet ();

			string sql1="select name as 名字,user_type as 用户类型 from enter";
			SqlDataAdapter a1=new SqlDataAdapter (sql1,conn);
			a1.Fill (dataset,"t1");
			dataGrid1.DataSource =dataset.Tables ["t1"];
			a1.Dispose ();
			dataset.Dispose ();
			conn.Dispose ();*/
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void button4_Click(object sender, System.EventArgs e)
		{//增加记录
			num=2;
			comboBox2.Visible=false;
			textBox4.Visible=true;
			pictureBox3.Visible=false;
			label2.Visible=true;
			label4.Visible=true;
			label5.Visible=true;
			textBox1.Visible=true;
			textBox2.Visible=true;
			comboBox1.Visible=true;
			label3.Visible=true;
			textBox3.Visible=true;			
		}

		private void button3_Click(object sender, System.EventArgs e)
		{//修改纪录
			num=1;
			comboBox2.Visible=true;
			textBox4.Visible=false;
			pictureBox3.Visible=false;
			label2.Visible=true;
			label4.Visible=true;
			label5.Visible=true;
			textBox1.Visible=true;
			textBox2.Visible=true;
			comboBox1.Visible=true;
			label3.Visible=true;
			textBox3.Visible=true;
			searchall a=new searchall();
			a.searchcom("select * from enter",this.comboBox2,"enter","enter.id");
		}

		private void button5_Click(object sender, System.EventArgs e)
		{//删除纪录
			num=3;
			comboBox2.Visible=true;
			textBox4.Visible=false;
			textBox1.Visible=false;	
			label4.Visible=false;
            pictureBox3.Visible=false;
			label2.Visible=false;
            label5.Visible=false;
			textBox2.Visible=false;
			comboBox1.Visible=false;
			label3.Visible=false;
			textBox3.Visible=false;	

			searchall a=new searchall();
			a.searchcom("select * from enter",this.comboBox2,"enter","enter.id");
		}

		private void button7_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void button6_Click(object sender, System.EventArgs e)
		{
			switch (num)
			{
				case 1:
					//修改纪录
					if(this.textBox1.Text.Length<1|this.textBox2.Text.Length<1|this.comboBox1.Text.Length<1)
					{
						MessageBox.Show("用户所有信息都必须填写!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
						return;
					}
					else if(this.textBox2.Text!=this.textBox3.Text)
					{
						MessageBox.Show("请确认你的密码!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
						textBox2.Text="";
						textBox3.Text="";
						return;
					}
					else
					{
						searchall a=new searchall();
						a.change("UPDATE enter SET name='"+this.textBox1.Text+"', passwd='"+this.textBox2.Text+"', user_type='"+this.comboBox1.Text+"' WHERE  id='"+this.comboBox2.Text+"'","enter");
					//UPDATE enter SET name='kjldskljklj',passwd='fddfdf',user_type='sdffdfdfff'where id='11'
					
					}
						
					break;
				case 2:
					//增加纪录
					if(this.textBox1.Text.Length<1|this.textBox2.Text.Length<1|this.comboBox1.Text.Length<1|this.textBox3.Text.Length<1)
					{
						MessageBox.Show("用户所有信息都必须填写!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
						return;
					}
					else if(this.textBox2.Text!=this.textBox3.Text)
					{
						MessageBox.Show("请确认你的密码!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
						textBox2.Text="";
						textBox3.Text="";
						return;
					}
					else 
					{
						searchall a=new searchall();
						a.add("INSERT INTO enter(id,name,passwd,user_type,times)VALUES('"+this.textBox4.Text+"','"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+this.comboBox1.Text+"','"+0+"')");
					}
					break;
				case 3:
					if(this.comboBox2.Text.Length<1)
					{
						MessageBox.Show("没有填写用户名字!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
						return;
					}
					else
					{
						searchall a=new searchall();
						a.delect("DELETE FROM enter WHERE id='"+this.comboBox2.Text+"'");
					}
					break;
			}
		}

		private void button8_Click(object sender, System.EventArgs e)
		{
			num=0;
			pictureBox3.Visible=true;
		}

		private void Form5_Load(object sender, System.EventArgs e)
		{//权限
			if(lzl.textBox2.Text=="管理员")
			{
				this.button3.Enabled=true;
				this.button4.Enabled=true;
				this.button5.Enabled=true;
			}
			else
			{
				this.button3.Enabled=false; 
				this.button4.Enabled=false;
				this.button5.Enabled=false;
                this.pictureBox3.Visible=true;
			}
				
				//权限
		}

		private void tabPage1_Click(object sender, System.EventArgs e)
		{
			num=0;
			pictureBox3.Visible=true;
		}

		}

	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -