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

📄 connect.cs

📁 Help Desk Pro has three different interfaces for all three domains of users, providing them with the
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient ;

namespace Final_Project_Alpha
{
	/// <summary>
	/// Summary description for connect.
	/// </summary>
	public class connect
	{
		SqlConnection strConn,strConn2;
		SqlDataAdapter myCommand1 , myCommand_a , myCommand_b , myCommand_group,rep_email, myCommand_news, myCommand_asset;
		SqlDataAdapter myCommand_action ;
		
		
		string connection = "server=(local);database=HelpDeskPro;User Id=faizan;Trusted_Connection=yes";
		string connection2 = "server=(local);database=UserAccounts;User Id=faizan;Trusted_Connection=yes";
		public connect()
		{
			//
			// TODO: Add constructor logic here
			//
		}




		public bool openDb() 
		{	
			try
			{
				strConn = new SqlConnection(connection);

				//SqlDataAdapter myCommand = new SqlDataAdapter("SELECT * FROM temp", strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return false;
			}

			return true;
		}

		public SqlConnection conn() 
		{	
			try
			{
				strConn = new SqlConnection(connection);
				
			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return strConn;
			}

			return strConn;
		}
		public SqlConnection conn2() 
		{	
			try
			{
				strConn2 = new SqlConnection(connection2);
				
			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return strConn2;
			}

			return strConn2;
		}





		public SqlDataAdapter adaptregister(string str) 
		{	
			try
			{
				myCommand1 = new SqlDataAdapter(str, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand1;
			}

			return myCommand1;
		}

		public SqlDataAdapter rep_email2(string str) 
		{	
			try
			{
				rep_email = new SqlDataAdapter(str, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return rep_email;
			}

			return rep_email;
		}






		public SqlDataAdapter adapt_a() 
		{	
			try
			{
				myCommand_a = new SqlDataAdapter("SELECT * FROM admin_ticket", strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_a;
			}

			return myCommand_a;
		}



		public SqlDataAdapter adapt_count(String login) 
		{	
			try
			{
				login += "_ticket";
				myCommand_a = new SqlDataAdapter("SELECT COUNT(*) FROM "+ login, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_a;
			}

			return myCommand_a;
		}


		public SqlDataAdapter adapt_all(String query) 
		{	
			try
			{
				
				myCommand_a = new SqlDataAdapter(query, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_a;
			}

			return myCommand_a;
		}
		
		public SqlDataAdapter adapt_news(String news) 
		{	
			try
			{
				myCommand_news = new SqlDataAdapter(news, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_news;
			}

			return myCommand_news;
		}
		
		public SqlDataAdapter adapt_asset(String asset) 
		{	
			try
			{
				myCommand_asset = new SqlDataAdapter(asset, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_asset;
			}

			return myCommand_asset;
		}


		public SqlDataAdapter adapt_assg(string assg) 
		{	
			try
			{
				//string  a = assg;
				myCommand_b = new SqlDataAdapter(assg, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_b;
			}

			return myCommand_b;
		}

		public SqlDataAdapter adapt_group(string str) 
		{	
			try
			{
				myCommand_group = new SqlDataAdapter(str, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_group;
			}

			return myCommand_group;
		}

		public SqlDataAdapter adapt_action() 
		{	
			try
			{
				myCommand_action = new SqlDataAdapter("SELECT * FROM actions", strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_action;
			}

			return myCommand_action;
		}

		public SqlDataAdapter adapt_count_actions() 
		{	
			try
			{
				
				myCommand_a = new SqlDataAdapter("SELECT COUNT(*) FROM actions", strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_a;
			}

			return myCommand_a;
		}




		public SqlDataAdapter adapt_actions() 
		{	
			try
			{
			string strjoin = "select group_name , groups.action_id , email" +
							" from groups , actions" +
							" where groups.action_id = actions.action_id";


				
			myCommand_a = new SqlDataAdapter(strjoin, strConn);

			}
			catch(Exception ex) 
			{
				Console.Write ("SQL Error" + ex.Message) ;
				return myCommand_a;
			}

			return myCommand_a;
		}


		







	}
}

⌨️ 快捷键说明

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