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

📄 employee.cs

📁 本系统为资产管理系统
💻 CS
字号:
using System;
using System.Data.SqlClient;
using System.Data;
namespace AssetManagement
{
	/// <summary>
	/// employee 的摘要说明。
	/// </summary>
	public class employee:Connection//继承
	{
		private SqlConnection connConnection;
		public SqlConnection getConnection
		{
			get
			{
				return new SqlConnection(this.getConnectionString);//用于连接数据库;
			}
			set
			{
			}
		}
		public employee()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public class employeeDetails
		{
			public string employeeNo;
			public string employeeName;
			public string address;
			public string workTelExt;
			public string homeTelNum;
			public string empEmail;
            public int sex;
			public float salary;
			public string epassword;
		}
		public void Open()
		{
			connConnection = this.getConnection;
			connConnection.Open();//打开数据库;
		}
		public int ExecuteSQL(string strCommandString)
		{
			SqlCommand cmdCommand = new SqlCommand(strCommandString,connConnection);
			int nAffected = cmdCommand.ExecuteNonQuery();
			return nAffected;
		}
		public void Close()
		{
			connConnection.Close();
		}
		public int employeeLogin(string employeeNo,string epassword)
		{
            //调用存储过程
            SqlCommand mycommand = new SqlCommand("EmployeeLogin",connConnection);
			mycommand.CommandType=CommandType.StoredProcedure;
			SqlParameter employee = new SqlParameter("@employeeNo",SqlDbType.VarChar,10);
			employee.Value = employeeNo;
			mycommand.Parameters.Add(employee);
			SqlParameter password = new SqlParameter("@epassword",SqlDbType.VarChar,20);
			password.Value = epassword;
			mycommand.Parameters.Add(password);
			SqlParameter employeeId = new SqlParameter("@IsTrue",SqlDbType.Int,4);
			employeeId.Direction = ParameterDirection.Output;
			mycommand.Parameters.Add(employeeId);
			mycommand.ExecuteNonQuery();
			if (employeeId.Value.ToString()!="")
			{
				return (int)employeeId.Value;
			}
			else
			{
				return -1;
			}

		}
		public bool addEmployee(string employeeNo,string employeeName,string address,string workTelExt,string homeTelNum,string empEmail,int sex,float salary)
		{
             SqlCommand mycommand = new SqlCommand("AddEmploee",connConnection);
			mycommand.CommandType = CommandType.StoredProcedure;
			SqlParameter EmployeeNo = new SqlParameter("@employeeNo",SqlDbType.VarChar,10);
			EmployeeNo.Value = employeeNo;
			mycommand.Parameters.Add(EmployeeNo);
			
			SqlParameter EmployeeName = new SqlParameter("@employeeName",SqlDbType.VarChar,30);
			EmployeeName.Value = employeeName;
			mycommand.Parameters.Add(EmployeeName);
			
			SqlParameter Address = new SqlParameter("@address",SqlDbType.VarChar,30);
			Address.Value = address;
			mycommand.Parameters.Add(Address);

			SqlParameter WorkTelExt = new SqlParameter("@workTelExt",SqlDbType.VarChar,30);
			WorkTelExt.Value = workTelExt;
			mycommand.Parameters.Add(WorkTelExt);

			SqlParameter HomeTelNum = new SqlParameter("@homeTelNum",SqlDbType.VarChar,30);
			HomeTelNum.Value = homeTelNum;
			mycommand.Parameters.Add(HomeTelNum);

			SqlParameter EmpEmail = new SqlParameter("@empEmail",SqlDbType.VarChar,30);
			EmpEmail.Value = empEmail;
			mycommand.Parameters.Add(EmpEmail);

			SqlParameter Sex = new SqlParameter("@sex",SqlDbType.Int,4);
			Sex.Value = sex;
			mycommand.Parameters.Add(Sex);

			SqlParameter Salary = new SqlParameter("@salary",SqlDbType.Float,8);
			Salary.Value = salary;
			mycommand.Parameters.Add(Salary);
			try
			{
				mycommand.ExecuteNonQuery();
				return true;
			}
			catch
			{
				return false;
			}
		}
		public bool modifyEmployee(string employeeNo,string employeeName,string address,string workTelExt,string homeTelNum,string empEmail,int sex,float salary)
		{
			SqlCommand mycommand = new SqlCommand("modifyEmployee",connConnection);
			mycommand.CommandType = CommandType.StoredProcedure;
			SqlParameter EmployeeNo = new SqlParameter("@employeeNo",SqlDbType.VarChar,10);
			EmployeeNo.Value = employeeNo;
			mycommand.Parameters.Add(EmployeeNo);
			
			SqlParameter EmployeeName = new SqlParameter("@employeeName",SqlDbType.VarChar,30);
			EmployeeName.Value = employeeName;
			mycommand.Parameters.Add(EmployeeName);
			
			SqlParameter Address = new SqlParameter("@address",SqlDbType.VarChar,30);
			Address.Value = address;
			mycommand.Parameters.Add(Address);

			SqlParameter WorkTelExt = new SqlParameter("@workTelExt",SqlDbType.VarChar,30);
			WorkTelExt.Value = workTelExt;
			mycommand.Parameters.Add(WorkTelExt);

			SqlParameter HomeTelNum = new SqlParameter("@homeTelNum",SqlDbType.VarChar,30);
			HomeTelNum.Value = homeTelNum;
			mycommand.Parameters.Add(HomeTelNum);

			SqlParameter EmpEmail = new SqlParameter("@empEmail",SqlDbType.VarChar,30);
			EmpEmail.Value = empEmail;
			mycommand.Parameters.Add(EmpEmail);

			SqlParameter Sex = new SqlParameter("@sex",SqlDbType.Int,4);
			Sex.Value = sex;
			mycommand.Parameters.Add(Sex);

			SqlParameter Salary = new SqlParameter("@salary",SqlDbType.Float,8);
			Salary.Value = salary;
			mycommand.Parameters.Add(Salary);
			try
			{
				mycommand.ExecuteNonQuery();
				return true;
			}
			catch
			{
				return false;
			}
		}
		public bool deleteEmployee(string employeeNo)
		{
			SqlCommand mycmd = new SqlCommand("DeleteEmployee",this.getConnection);
			mycmd.CommandType  = CommandType.StoredProcedure;

			SqlParameter EmployeeNo = new SqlParameter("@employeeNo",SqlDbType.VarChar,10);
			EmployeeNo.Value = employeeNo;
			mycmd.Parameters.Add(EmployeeNo);

			try
			{
				mycmd.ExecuteNonQuery();
				return true;
			}
			catch
			{
				return false;
			}
		}

	}
}

⌨️ 快捷键说明

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