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

📄 bankmanageform.cs

📁 银行数据库的操作人员管理平台,主要对操作的柜员帐号进行管理,C#+SQL开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.label8.Name = "label8";
			this.label8.TabIndex = 17;
			this.label8.Text = "权限:";
			// 
			// txtModifyPwd
			// 
			this.txtModifyPwd.Location = new System.Drawing.Point(120, 88);
			this.txtModifyPwd.Name = "txtModifyPwd";
			this.txtModifyPwd.Size = new System.Drawing.Size(184, 21);
			this.txtModifyPwd.TabIndex = 16;
			this.txtModifyPwd.Text = "";
			// 
			// txtModifyWorkID
			// 
			this.txtModifyWorkID.Location = new System.Drawing.Point(120, 56);
			this.txtModifyWorkID.Name = "txtModifyWorkID";
			this.txtModifyWorkID.Size = new System.Drawing.Size(184, 21);
			this.txtModifyWorkID.TabIndex = 15;
			this.txtModifyWorkID.Text = "";
			// 
			// txtModifyName
			// 
			this.txtModifyName.Location = new System.Drawing.Point(120, 24);
			this.txtModifyName.Name = "txtModifyName";
			this.txtModifyName.Size = new System.Drawing.Size(184, 21);
			this.txtModifyName.TabIndex = 14;
			this.txtModifyName.Text = "";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(8, 88);
			this.label9.Name = "label9";
			this.label9.TabIndex = 13;
			this.label9.Text = "操作帐号密码:";
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(8, 56);
			this.label10.Name = "label10";
			this.label10.TabIndex = 12;
			this.label10.Text = "操作人工号:";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(8, 24);
			this.label7.Name = "label7";
			this.label7.TabIndex = 0;
			this.label7.Text = "操作人:";
			// 
			// btnQuery
			// 
			this.btnQuery.Location = new System.Drawing.Point(360, 16);
			this.btnQuery.Name = "btnQuery";
			this.btnQuery.TabIndex = 2;
			this.btnQuery.Text = "查询";
			this.btnQuery.Click += new System.EventHandler(this.btnQuery_Click);
			// 
			// txtAccQuery
			// 
			this.txtAccQuery.Location = new System.Drawing.Point(136, 16);
			this.txtAccQuery.Name = "txtAccQuery";
			this.txtAccQuery.Size = new System.Drawing.Size(184, 21);
			this.txtAccQuery.TabIndex = 1;
			this.txtAccQuery.Text = "";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(8, 16);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(112, 23);
			this.label6.TabIndex = 0;
			this.label6.Text = "请输入操作帐号:";
			// 
			// ListOperAccount
			// 
			this.ListOperAccount.Controls.Add(this.dataGrid);
			this.ListOperAccount.Location = new System.Drawing.Point(4, 21);
			this.ListOperAccount.Name = "ListOperAccount";
			this.ListOperAccount.Size = new System.Drawing.Size(496, 231);
			this.ListOperAccount.TabIndex = 2;
			this.ListOperAccount.Text = "列出所有帐号";
			// 
			// sqlConnection
			// 
			this.sqlConnection.ConnectionString = "Persist Security Info=False;User ID=sa;Initial Catalog=NITPRO";
			// 
			// sqlCommand
			// 
			this.sqlCommand.Connection = this.sqlConnection;
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.Connection = this.sqlConnection;
			// 
			// sqlDataAdapter
			// 
			this.sqlDataAdapter.DeleteCommand = this.sqlDeleteCommand1;
			this.sqlDataAdapter.InsertCommand = this.sqlInsertCommand1;
			this.sqlDataAdapter.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// dataSet
			// 
			this.dataSet.DataSetName = "NewDataSet";
			this.dataSet.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// dataGrid
			// 
			this.dataGrid.DataMember = "";
			this.dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid.Location = new System.Drawing.Point(8, 16);
			this.dataGrid.Name = "dataGrid";
			this.dataGrid.Size = new System.Drawing.Size(480, 208);
			this.dataGrid.TabIndex = 0;
			// 
			// BankManageForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(536, 310);
			this.Controls.Add(this.tabControl);
			this.Name = "BankManageForm";
			this.Text = "银行管理系统";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.BankManageForm_Closing);
			this.tabControl.ResumeLayout(false);
			this.CreateOperAccount.ResumeLayout(false);
			this.ModifyOperAccount.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.ListOperAccount.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataSet)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new BankManageForm());
		}

		private void btnCreateAccount_Click(object sender, System.EventArgs e)
		{
			//获取姓名,工号,帐户名,密码,权限
			string strname="",strworkid="",straccount="",strpassword="",strright="";
			strname=txtName.Text.Trim();
			strworkid=txtWorkID.Text.Trim();
			straccount=txtAccount.Text.Trim();
			strpassword=txtPassword.Text.Trim();
			if(btnReadWrite.Checked)
				strright="readwrite";
			if(btnList.Checked)
				strright="listonly";
				
			//判断所有信息是否都输入完整了
			if(strname!="" && strworkid!="" && straccount!="" && strpassword!="" && strright!="")
			{
				//查找操作员表,看帐户名是否已存在
				string sql;
				sql="select * from OperAccount where name='"+straccount+"'";
				sqlCommand.CommandText=sql;
				
				string str=(string)sqlCommand.ExecuteScalar();	
				//帐户名不存在,可以注册			
				if(str==null)
				{
					sql="insert into OperAccount (name,password,authority,username,userworkid) values('"+straccount +"','"+strpassword+"','"+strright+"','"+strname+"','"+strworkid+"')";
					sqlCommand.CommandText=sql;
					sqlCommand.ExecuteNonQuery();
					MessageBox.Show("操作帐号添加成功");
				}
				else
				{
					MessageBox.Show("操作帐号已存在");
				}
			}
			else
			{
				MessageBox.Show("请完整输入");
			}
		}

		private void BankManageForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			//程序关闭时关闭SQL连接,断开数据库
			sqlConnection.Close();
		}

		private void btnQuery_Click(object sender, System.EventArgs e)
		{
			//获得要查询的帐户名并检索
			string straccount="";
			straccount=txtAccQuery.Text.Trim();
			string sql="select * from OperAccount where name='"+straccount+"'";
			sqlCommand.CommandText=sql;
			string str=(string)sqlCommand.ExecuteScalar();	

			//如果帐户名存在
			if(str!=null)
			{
				//读取此帐号的所有详细信息
				sql="select * from OperAccount where name='"+straccount+"'";
				sqlDataAdapter.SelectCommand.CommandText=sql;
				dataSet.Reset();
				sqlDataAdapter.Fill(dataSet,"OperAccount");
				
				//并添加至编辑框
				txtModifyName.Text=dataSet.Tables[0].Rows[0]["username"].ToString().Trim();
				txtModifyWorkID.Text=dataSet.Tables[0].Rows[0]["userworkid"].ToString().Trim();
				txtModifyPwd.Text=dataSet.Tables[0].Rows[0]["password"].ToString().Trim();

				string right=dataSet.Tables[0].Rows[0]["authority"].ToString().Trim();
				if(right=="readwrite")
					btnModifyRW.Checked=true;
				if(right=="listonly")
					btnModifyList.Checked=true;

			}
			else
			{
				MessageBox.Show("操作帐号不存在");
			}

		}

		private void btnModify_Click(object sender, System.EventArgs e)
		{
			//待管理员编辑好后,获得编辑后的内容
			string strname="",strworkid="",straccount="",strpassword="",strright="";
			strname=txtModifyName.Text.Trim();
			strworkid=txtModifyWorkID.Text.Trim();
			straccount=txtAccQuery.Text.Trim();
			strpassword=txtModifyPwd.Text.Trim();
			if(btnModifyRW.Checked)
				strright="readwrite";
			if(btnModifyList.Checked)
				strright="listonly";
			
			//编辑后各项内容不能为空
			if(strname!="" && strworkid!="" && straccount!="" && strpassword!="" && strright!="")
			{
				string sql;
				sql="select * from OperAccount where name='"+straccount+"'";
				sqlCommand.CommandText=sql;
				
				string str=(string)sqlCommand.ExecuteScalar();	
				
				//如果帐号存在
				if(str!=null)
				{
					//更新帐号的内容
					sql="update OperAccount set password='" +strpassword+ "', authority='" +strright+ "',  username='" +strname+ "', userworkid='" +strworkid+ "' where name='" +straccount+ "'";
					sqlCommand.CommandText=sql;
					sqlCommand.ExecuteNonQuery();
					MessageBox.Show("修改成功");
				}
				else
				{
					MessageBox.Show("操作帐号不存在");
				}
			}
			else
			{
				MessageBox.Show("请完整输入");
			}
		}

		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			//获取帐户名
			string straccount="";
			straccount=txtAccQuery.Text.Trim();
			if(straccount!="")
			{
				string sql;
				sql="select * from OperAccount where name='"+straccount+"'";
				sqlCommand.CommandText=sql;
				
				string str=(string)sqlCommand.ExecuteScalar();	
				
				//查询帐号是否存在
				if(str!=null)
				{
					//将其删除
					sql="delete from OperAccount where name='"+straccount+"'";
					sqlCommand.CommandText=sql;
					sqlCommand.ExecuteNonQuery();
					MessageBox.Show("帐号已删除");

					//编辑框清空
					txtAccQuery.Text="";
					txtModifyName.Text="";
					txtModifyWorkID.Text="";
					txtModifyPwd.Text="";
					btnModifyRW.Checked=false;
					btnModifyList.Checked=false;
				}
				else
				{
					MessageBox.Show("操作帐号不存在");
				}
			}
			else
			{
				MessageBox.Show("操作帐号没输入");
			}
		}

		private void tabControl_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			//当换页换至"ListOperAccount",即列出所有操作员这页时
			if(tabControl.SelectedTab==ListOperAccount)
			{
				//为了避免每次重复添加,一开始进行清空
				dataSet.Clear();
				
				//列表列出所有的行
				string sql="select * from OperAccount";
				sqlDataAdapter.SelectCommand.CommandText=sql;
				sqlDataAdapter.Fill(dataSet,"OperAccount");

				dataGrid.DataSource=dataSet.Tables[0];
			
			
			}
		}
	}
}

⌨️ 快捷键说明

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