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

📄 config.cs

📁 为湖北省教委、湖北省就业指导中心订做的学历查询系统
💻 CS
字号:
using System;
using System.Xml;
using System.IO;

namespace WindowsApplication3
{
	/// <summary>
	/// 路径配置类
	/// </summary>
	public class Config
	{
		private static  Config m_config = new Config( );

		private Config()
		{
			
		}

		public static Config GetInstance( )
		{
			return m_config;
		}
		/// <summary>
		/// 从config.xml文件中读出数据库路径
		/// </summary>
		/// <returns>数据库路径</returns>
		public static string GetPath( )
		{
			XmlDocument myxml = new XmlDocument();
			FileStream mystr = new FileStream("config.xml",FileMode.Open);
			myxml.Load( mystr );
			mystr.Close( );
			XmlElement element = (XmlElement)myxml.DocumentElement.ChildNodes[0];
			string path = element.ChildNodes[0].Value;
			return path;
		}

		/// <summary>
		/// 查找是否已经设置源数据库
		/// </summary>
		/// <returns>true为已经设置,false为没有设置</returns>
		public static bool HasSet( )
		{
			XmlDocument myDocument = new XmlDocument( );
			FileStream myStream= new FileStream( "config.xml",FileMode.Open );
			myDocument.Load( myStream );
			myStream.Close( );
			XmlElement setElment = (XmlElement)myDocument.DocumentElement.ChildNodes[1];
			string temp = setElment.ChildNodes[0].Value;
			if ( temp == "Set" )
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		public static void SetPath( string path )
		{
			XmlDocument myDocument = new XmlDocument( );
			FileStream myStream= new FileStream( "config.xml",FileMode.Open );
			myDocument.Load( myStream );
			myStream.Close( );
			XmlElement dbpathElement = (XmlElement)myDocument.DocumentElement.ChildNodes[0];
			XmlElement setElement =(XmlElement)myDocument.DocumentElement.ChildNodes[1];
			dbpathElement.ChildNodes[0].Value = path;
			setElement.ChildNodes[0].Value = "Set";
			myDocument.Save( "config.xml" );
		}
		/// <summary>
		/// 根据传入查询人员的学历类型和毕业时间来给出表名
		/// </summary>
		/// <param name="diploma">学历类型</param>
		/// <param name="yearOfGraduation">毕业时间</param>
		/// <returns>表名</returns>
		public static string GetTableName( string diploma, string yearOfGraduation )
		{
			string tempString = "";
			if ( int.Parse(yearOfGraduation) <  2001 )
			{
				tempString = "2000";
			}
			else
			{
				tempString = yearOfGraduation;
			}
			if ( diploma == "成人" )
			{
				return "dzzc42cr" +  tempString;
			}
			else if( diploma == "研究生" )
			{
				return "dzzc42yjs" +  tempString;
			}
			else if ( diploma == "普通全日制" )
			{
				return "dzzc42pt" +  tempString;
			}
			else if( diploma == "网络教育" )
			{
				return "dzzc42wl" +  tempString;
			}
			else
			{
				return "dzzc42zxks" +  tempString;
			}
		}

		public static string GetDir( string diplomatype)
		{
			return Config.GetPath( ) + "\\" + diplomatype + "\\";
		}

	}
}

⌨️ 快捷键说明

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