?? staticclass.cs
字號:
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
namespace PK
{
/// <summary>
/// staticClass 的摘要說明。
/// </summary>
public class staticClass
{
public staticClass()
{
//
// TODO: 在此處添加構(gòu)造函數(shù)邏輯
//
}
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}學(xué)生人數(shù):{4}教學(xué)班號:{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;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -