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

📄 login.cs

📁 利用matlab进行的盲均衡MMA算法仿真
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OracleClient;

namespace Reset
{
	/// <summary>
	/// Login 的摘要说明。
	/// </summary>
	public class Login : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		public string usrname,usrpwd;
		public string idgrp,idusrgrp,usrgrpname;
		private System.Windows.Forms.TextBox txtUsrpwd;
		private System.Windows.Forms.TextBox txtUsrname;
		private System.Data.OracleClient.OracleConnection oracleConnection1;

		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Login()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		public bool Logined 
		{
			get { return _logined; }
		}

		private bool _logined = false;
		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.txtUsrname = new System.Windows.Forms.TextBox();
			this.txtUsrpwd = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.oracleConnection1 = new System.Data.OracleClient.OracleConnection();
			this.SuspendLayout();
			// 
			// txtUsrname
			// 
			this.txtUsrname.Location = new System.Drawing.Point(120, 24);
			this.txtUsrname.Name = "txtUsrname";
			this.txtUsrname.Size = new System.Drawing.Size(200, 21);
			this.txtUsrname.TabIndex = 0;
			this.txtUsrname.Text = "";
			// 
			// txtUsrpwd
			// 
			this.txtUsrpwd.Location = new System.Drawing.Point(120, 56);
			this.txtUsrpwd.Name = "txtUsrpwd";
			this.txtUsrpwd.PasswordChar = '*';
			this.txtUsrpwd.Size = new System.Drawing.Size(200, 21);
			this.txtUsrpwd.TabIndex = 1;
			this.txtUsrpwd.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 24);
			this.label1.Name = "label1";
			this.label1.TabIndex = 2;
			this.label1.Text = "用户名";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 56);
			this.label2.Name = "label2";
			this.label2.TabIndex = 3;
			this.label2.Text = "密码";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(56, 96);
			this.button1.Name = "button1";
			this.button1.TabIndex = 4;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(200, 96);
			this.button2.Name = "button2";
			this.button2.TabIndex = 5;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// oracleConnection1
			// 
			this.oracleConnection1.ConnectionString = "user id=telbizusr;data source=orcl;password=njtu";
			// 
			// Login
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(343, 127);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtUsrpwd);
			this.Controls.Add(this.txtUsrname);
			this.MaximizeBox = false;
			this.Name = "Login";
			this.Text = "登录...";
			this.Load += new System.EventHandler(this.Login_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			txt_check();
			//usrgroup_check();
		}
		private void txt_check()
		{
			if(txtUsrname.Text==""||txtUsrpwd.Text=="")
			{
				MessageBox.Show("用户名或密码不能为空");
			}

			else 
			{
				usrname=txtUsrname.Text;
				usrpwd=txtUsrpwd.Text;
				usrgroup_check();
			}
			
		
		}
		private void usrgroup_check()
		{
			idgrp=null;
			idusrgrp=null;
			usrgrpname=null;//初始化全局变量
			oracleConnection1.Open();
			//OracleCommand cmd = new OracleCommand("select count(*) from TB_USER where USERNAME='" + usrname +"'and USERPASSWORD='" + usrpwd + "'", oracleConnection1);
			//int count =Convert.ToInt32( cmd.ExecuteScalar());
			//if (count > 0)
			//{
			string select = "select IDOFUSER from TB_USER where USERNAME='"+txtUsrname.Text+"' and USERPASSWORD='"+txtUsrpwd.Text+"'";	
			OracleCommand cmd = new OracleCommand(select,oracleConnection1);
			//OracleDataAdapter da = new OracleDataAdapter(txt,oracleConnection1);
			//DataSet myset = new DataSet();
			//da.Fill(myset);
			
			OracleDataReader sr = cmd.ExecuteReader();
			while(sr.Read())
			{
				idgrp = sr["IDOFUSER"].ToString();
			}
            
			//int i  = myset.Tables[0].Rows.Count;
			//idgrp = myset.Tables[0].Rows[0]["IDOFUSER"].ToString();
			string select1= "select IDOFUSERGROUP from TB_USER_IN_GROUP where IDOFUSER='"+idgrp+"'";
			OracleCommand cmd1 = new OracleCommand(select1,oracleConnection1);
			OracleDataReader sr1 = cmd1.ExecuteReader();
			while(sr1.Read())
			{
				idusrgrp = sr1["IDOFUSERGROUP"].ToString();
			}

			string select2= "select USERGROUPNAME from TB_USERGROUP where IDOFUSERGROUP='"+idusrgrp+"'";
			OracleCommand cmd2 = new OracleCommand(select2,oracleConnection1);
			OracleDataReader sr2 = cmd2.ExecuteReader();
			while(sr2.Read())
			{
				usrgrpname = sr2["USERGROUPNAME"].ToString();
			}
			//MessageBox.Show("您的身份是"usrgrpname);
			if (usrgrpname=="管理员") 
			{
				this.DialogResult = DialogResult.OK;
				

			}
			else 
			{
				MessageBox.Show("请您确定您的权限", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				
				//this.DialogResult = DialogResult. Cancel;
				txtUsrname.Text="";txtUsrpwd.Text="";

			}
          

			oracleConnection1.Close();
        
		}

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

		private void Login_Load(object sender, System.EventArgs e)
		{
		
		}

		private void oracleConnection1_InfoMessage(object sender, System.Data.OracleClient.OracleInfoMessageEventArgs e)
		{
		
		}
		
	}
}

⌨️ 快捷键说明

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