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

📄 empdb.cs

📁 专业的办公oa代码下载 c#语言编写 三层结构
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;


namespace qminoa.DA
{
	public class EmpDB
	{
		
		public String[] Login(String loginid, String password) 
		{    
             String[] CheckLogin;
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysEmpLogin", myConnection);
			
			myCommand.CommandType = CommandType.StoredProcedure;

			SqlParameter parameterLoginID = new SqlParameter("@loginid", SqlDbType.VarChar,50);
			parameterLoginID.Value = loginid;
			myCommand.Parameters.Add(parameterLoginID);
			SqlParameter parameterPassword = new SqlParameter("@password", SqlDbType.VarChar, 50);
			parameterPassword.Value = password;
			myCommand.Parameters.Add(parameterPassword);
			SqlParameter parameterEmpID = new SqlParameter("@empid", SqlDbType.Int, 4);
			parameterEmpID.Direction = ParameterDirection.Output;
			myCommand.Parameters.Add(parameterEmpID);

			SqlParameter parameterReason = new SqlParameter("@reason", SqlDbType.VarChar,50);
			parameterReason.Direction = ParameterDirection.Output;
			myCommand.Parameters.Add(parameterReason);

			myConnection.Open();
			myCommand.ExecuteNonQuery();
			myConnection.Close();

			string LoginID;
			LoginID=parameterEmpID.Value.ToString();
			string Result;
			if(parameterReason.Value.ToString ()=="access")
				Result="成功登录";
			else if(parameterReason.Value.ToString ()=="noEmp")
			{
				Result="用户名错误";
				LoginID="usererror";
			}
			else if(parameterReason.Value.ToString ()=="pError")
			{
				Result="密码错误";
				LoginID="pwderror";
			}
			else 
			{
				Result="帐号被禁用";
				LoginID="noacount";
			}
              CheckLogin=new string []
				  {
					LoginID,
				  Result
				  };
			return CheckLogin;



		}
		public bool ChangePassword(string empid,string newpassword)
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysEmpChangePassword", myConnection);
			
			myCommand.CommandType = CommandType.StoredProcedure;

			SqlParameter parameterEmpID = new SqlParameter("@empid", SqlDbType.Int);
			parameterEmpID.Value = Convert.ToInt16(empid);
			myCommand.Parameters.Add(parameterEmpID);

			SqlParameter parameterPassword = new SqlParameter("@password", SqlDbType.VarChar,50);
			parameterPassword.Value = newpassword;
			myCommand.Parameters.Add(parameterPassword);

			try
			{
				myConnection.Open();
				int result = myCommand.ExecuteNonQuery();
				myConnection.Close();
			}
			catch
			{
				return false;
			}
				return true;
		}
	}
}

⌨️ 快捷键说明

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