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

📄 staticclass.cs

📁 排课系统
💻 CS
字号:
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace PK
{
	/// <summary>
	/// staticClass 的摘要说明。
	/// </summary>
	public class staticClass
	{
		public staticClass()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public static int countCourse()
		{
			Connection c = new Connection();
			int i = 0;
			SqlConnection conn = new SqlConnection(c.getConnectionString);
			conn.Open();
			//string str = classNo;
			string strsql = "select distinct courseNo from course";
			SqlCommand cmd = new SqlCommand(strsql,conn);
			SqlDataReader dr = cmd.ExecuteReader();
			while (dr.Read())
			{
				//if (str == Convert.ToString(dr["classNo"]))
					i++;
			}
			dr.Close();
			conn.Close();
			return i;
		}
		public static bool isOk(course co,ArrayList Course)
		{
			foreach (course co1 in Course)
			{
				if (co.CourseNo != co1.CourseNo)
				{
					if (co.TeacherNo == co1.TeacherNo)
						return false;
					if (co.ClassNo == co1.ClassNo)
						return false;
					if (co.StudyClassNo == co1.StudyClassNo)
						return false;
				}
			}
			return true;
		}
		public static bool isFinished(ArrayList Course)
		{
			foreach (course co in Course)
			{
				if (co.ClassNo == null||co.ClassTime == null)
					return false;		
			}
			return true;
		}
		public static bool isAllNull(ArrayList [,] time,int n,int m,int start)
		{
			for (int i = start;i < n;i++)
				for (int j = 0;j < m;j++)
				{
					if (time[i,j] != null)
						return false;
				}
			return true;
		}
		public static void Print(ArrayList Course)
		{
			int i = 0;
			foreach (course co1 in Course)
			{
				i = Convert.ToInt32(co1.ClassTime);
				//Console.WriteLine("课程号:{0}上课时间:{1}教室号:{2}教师号:{3}学生人数:{4}教学班号:{5}",co1.CourseNo,co1.ClassTime,co1.TeacherNo,co1.StudentNum,co1.StudyClassNo);
			}
		}
		public static bool isUsed(string classNo)
		{
			Connection c = new Connection();
			SqlConnection conn = new SqlConnection(c.getConnectionString);
			conn.Open();
			string str = classNo;
			string strsql = "select * from course";
			SqlCommand cmd = new SqlCommand(strsql,conn);
			SqlDataReader dr = cmd.ExecuteReader();
			while (dr.Read())
			{
				if (str == Convert.ToString(dr["classNo"]))
					return true;
			}
			dr.Close();
			conn.Close();
			return false;
		}
		public static bool isTeacher(string teacherNo)
		{
			Connection c = new Connection();
			SqlConnection conn = new SqlConnection(c.getConnectionString);
			conn.Open();
			string str = teacherNo;
			string strsql = "select * from course";
			SqlCommand cmd = new SqlCommand(strsql,conn);
			SqlDataReader dr = cmd.ExecuteReader();
			while (dr.Read())
			{
				if (str == Convert.ToString(dr["teacherNo"]))
			    	return true;
			}
			dr.Close();
			conn.Close();
			return false;
		}
		public static void clearPk()
		{
			Connection c = new Connection();
			SqlConnection conn = new SqlConnection(c.getConnectionString);
			conn.Open();
			string str = "update course set classNo = null,classTime = null";
			SqlCommand cmd = new SqlCommand(str,conn);
			cmd.ExecuteNonQuery();
			conn.Close();
		}
		public static bool isHaveConsequents()
		{
			Connection c = new Connection();
			string s = "";
			SqlConnection conn = new SqlConnection(c.getConnectionString);
			conn.Open();
			string sql = "select * from course";
			SqlCommand cmd = new SqlCommand(sql,conn);
			SqlDataReader dr = cmd.ExecuteReader();
			while (dr.Read())
			{
				if (s == Convert.ToString(dr["classTime"]))
				{
					return false;
				}
			}
			dr.Close();
			conn.Close();
			return true;
		}

	}
}

⌨️ 快捷键说明

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