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

📄 ope_manage.cs

📁 学生管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.label1.Text = "学号:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(18, 280);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(66, 18);
			this.label2.TabIndex = 23;
			this.label2.Text = "姓  名:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(18, 255);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(66, 18);
			this.label3.TabIndex = 24;
			this.label3.Text = "密  码:";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(18, 311);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(66, 18);
			this.label4.TabIndex = 25;
			this.label4.Text = "用户权限:";
			// 
			// textBox2
			// 
			this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox2.Location = new System.Drawing.Point(96, 255);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(114, 21);
			this.textBox2.TabIndex = 26;
			this.textBox2.Text = "";
			// 
			// textBox3
			// 
			this.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox3.Location = new System.Drawing.Point(96, 280);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(114, 21);
			this.textBox3.TabIndex = 27;
			this.textBox3.Text = "";
			// 
			// textBox4
			// 
			this.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.textBox4.Location = new System.Drawing.Point(96, 305);
			this.textBox4.Name = "textBox4";
			this.textBox4.Size = new System.Drawing.Size(114, 21);
			this.textBox4.TabIndex = 28;
			this.textBox4.Text = "";
			// 
			// button3
			// 
			this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.button3.Location = new System.Drawing.Point(324, 299);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(54, 31);
			this.button3.TabIndex = 29;
			this.button3.Text = "取消";
			// 
			// groupBox3
			// 
			this.groupBox3.Location = new System.Drawing.Point(222, 286);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(174, 6);
			this.groupBox3.TabIndex = 30;
			this.groupBox3.TabStop = false;
			// 
			// groupBox4
			// 
			this.groupBox4.Location = new System.Drawing.Point(18, 330);
			this.groupBox4.Name = "groupBox4";
			this.groupBox4.Size = new System.Drawing.Size(360, 6);
			this.groupBox4.TabIndex = 31;
			this.groupBox4.TabStop = false;
			// 
			// groupBox5
			// 
			this.groupBox5.Location = new System.Drawing.Point(6, 218);
			this.groupBox5.Name = "groupBox5";
			this.groupBox5.Size = new System.Drawing.Size(210, 112);
			this.groupBox5.TabIndex = 32;
			this.groupBox5.TabStop = false;
			// 
			// txtID
			// 
			this.txtID.Location = new System.Drawing.Point(36, 187);
			this.txtID.Name = "txtID";
			this.txtID.Size = new System.Drawing.Size(42, 21);
			this.txtID.TabIndex = 33;
			this.txtID.Text = "";
			// 
			// Ope_manage
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(402, 341);
			this.Controls.Add(this.groupBox4);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.textBox4);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.groupBox5);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.txtID);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "Ope_manage";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "操作员管理";
			this.Load += new System.EventHandler(this.Ope_manage_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void Ope_manage_Load(object sender, System.EventArgs e)
		{
			dataGrid1.SetDataBinding(mydataset,"student");
//			txtID.DataBindings.Add("text",mydataset,"student.id");
			textBox1.DataBindings.Add("text",mydataset,"student.用户ID");
			textBox3.DataBindings.Add("text",mydataset,"student.用户姓名");
			textBox2.DataBindings.Add("text",mydataset,"student.用户密码");
			textBox4.DataBindings.Add("text",mydataset,"student.用户权限");
			bManager = this.BindingContext[mydataset,"student"];
		}

		private void btnIncrease_Click(object sender, System.EventArgs e)
		{
//			textBox1.Enabled = textBox2.Enabled = textBox3.Enabled = textBox4.Enabled = true; 
			textBox1.Text =textBox2.Text =textBox3.Text = textBox4.Text = "";
		}

		private void btndelete_Click(object sender, System.EventArgs e)
		{
			DialogResult result = MessageBox.Show("你是否真的要删除该项","注意",MessageBoxButtons.YesNo,MessageBoxIcon.Stop);
			if(result == DialogResult.Yes)
			{
				try
				{				
					DataTable dataTable = mydataset.Tables["student"];					
					int c = dataGrid1.CurrentRowIndex;
					dataTable.Rows[c].Delete();
					int nRows = thisAdapter.Update(mydataset,"student");
					mydataset.AcceptChanges();
					dataGrid1.SetDataBinding(mydataset,"student");	
				}
				catch(Exception e1)
				{
					MessageBox.Show(e1.Message);
				}
			}
		}

		private void btnModification_Click(object sender, System.EventArgs e)
		{
			try
			{
				SqlConnection thisConnection=new SqlConnection("integrated security=SSPI;data source=.;persist security info=False;initial catalog=xxgcx");
				SqlDataAdapter da = new SqlDataAdapter("update student set mm='"+this.textBox2.Text.Trim()+"',xm='"+this.textBox3.Text.Trim()+"',Op_level='"+this.textBox4.Text.Trim()+"' where xh='"+this.textBox1.Text.Trim()+"'",thisConnection);
				DataSet ds = new DataSet();			
				da.Fill(ds,"test");
				MessageBox.Show("恭喜 ,修改成功");
				dataGrid1.SetDataBinding(mydataset,"student");
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			try
			{
				DataTable dt = mydataset.Tables["student"];			
				DataRow newRow = dt.NewRow();
				newRow["用户ID"] = textBox1.Text.Trim();			
				newRow["用户姓名"] = textBox3.Text.Trim();
				newRow["用户密码"] = textBox2.Text.Trim();
				newRow["用户权限"] = textBox4.Text.Trim();	
				dt.Rows.Add(newRow);
				thisAdapter.Update(mydataset,"student");
				dt.AcceptChanges();
				MessageBox.Show("你的信息已经被成功的保存到数据库","恭喜");
			}
			catch(Exception e1)
			{
				//					MessageBox.Show("数据库'用户名'被占用,本窗体将关闭","出错");					
				MessageBox.Show(e1.Message);
				this.Close();				
				return;
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			bManager.Position -=1;	
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			bManager.Position +=1;
		}
	}
}

⌨️ 快捷键说明

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