private void InsertCoursesSimpleMap(List <string> strDistinctTeacherID)
 {
     for (int i = 0; i < strDistinctTeacherID.Count; i++)
     {
         List <string> strDD = new List <string>();
         strDD = AddSQLStringToDAL.GetDistinctStrings("TabAllCourses", "TimeAndArea", "TeacherID", strDistinctTeacherID[i].ToString());//获取TimeAndArea
         for (int k = 0; k < strDD.Count; k++)
         {
             List <string> strResult = new List <string>();
             strResult = SplitString.GetSplitCountAndDetails(strDD[k]);
             DataTable dt = AddSQLStringToDAL.GetDataTableBysql("select * from TabAllCourses where TeacherID = '" + strDistinctTeacherID[i].ToString() + "' and TimeAndArea = '" + strDD[k].ToString() + "'");
             for (int j = 0; j < (strResult.Count / 4); j++)
             {
                 string WeekRange = SplitString.GetWithoutWeek(strResult[j * 4 + 0].ToString());//如果想用空格隔开,只是在最后加一个空格(以,作为例子试的)
                 string Week      = strResult[j * 4 + 1].ToString();
                 string Time      = strResult[j * 4 + 2].ToString();
                 string Area      = strResult[j * 4 + 3].ToString();
                 string Course    = dt.Rows[0]["Course"].ToString().Trim();
                 if (AddSQLStringToDAL.InsertTabTeachers("TabTeacherCourseSimpleMap", strDistinctTeacherID[i].ToString(), dt.Rows[0]["TeacherName"].ToString(), Course, WeekRange, Week, Time, strDD[k].ToString(), dt.Rows[0]["Class"].ToString(), dt.Rows.Count.ToString(), dt.Rows[0]["TeacherDepartment"].ToString(), dt.Rows[0]["StudentDepartment"].ToString(), Area))
                 {
                 }
             }
             dt.Clear();
         }
     }
 }
    private void InitialPWD()//密码加密
    {
        List <string> str = new List <string>();

        str = AddSQLStringToDAL.GetDistinctStrings("TabAllTeachers", "UserID");
        for (int i = 0; i < str.Count; i++)
        {
            if (AddSQLStringToDAL.UpdateTabTeachers("TabAllTeachers", FormsAuthentication.HashPasswordForStoringInConfigFile(str[i].ToString(), "MD5").ToString(), str[i].ToString()))
            {
                lblMessage3.Text = "正在初始化密码...";
            }
        }


        List <string> str1 = new List <string>();

        str1 = AddSQLStringToDAL.GetDistinctStrings("TabAllTeachers", "UserID");
        for (int i = 0; i < str1.Count; i++)
        {
            if (AddSQLStringToDAL.UpdateTabTeachers("TabTeachers", FormsAuthentication.HashPasswordForStoringInConfigFile(str[i].ToString(), "MD5").ToString(), str[i].ToString()))
            {
                lblMessage3.Text = "正在初始化密码...";
            }
        }
        List <string> str2 = new List <string>();

        str2 = AddSQLStringToDAL.GetDistinctStrings("TabAllTeachers", "UserID");
        for (int i = 0; i < str2.Count; i++)
        {
            if (AddSQLStringToDAL.UpdateTabTeachers("TabOtherTeachers", PWDProcess.MD5Encrypt(str2[i].ToString(), PWDProcess.CreateKey(str2[i].ToString())), str2[i].ToString()))
            {
                lblMessage3.Text = "正在初始化密码...";
            }
        }
    }
    private void InsertTeacherStatus()
    {
        Clear();
        List <string> str = new List <string>();

        str = AddSQLStringToDAL.GetDistinctStrings("TabAllCourses", "TeacherID");
        lblMessage3.Text = "第一步:教师信息对比完成!正在进行第二步...";
        InsertCoursesSimpleMap(str);
        lblMessage3.Text = "所有信息核对无误!请对数据进行处理";
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (chkToLeader.Checked == false && chkToSecretary.Checked == false && chkToTeacher.Checked == false)
        {
            lblMessage.Text = "请选中要发布通知的对象!";
        }
        else
        {
            if (txtxMessage.Text == "")
            {
                lblMessage.Text = "通知不能为空!";
            }
            else
            {
                List <string> strSum = new List <string>();
                List <string> strID1 = new List <string>();
                List <string> strID2 = new List <string>();
                List <string> strID3 = new List <string>();
                List <string> strID4 = new List <string>();

                if (chkToLeader.Checked)//找出校领导ID
                {
                    strID1 = AddSQLStringToDAL.GetDistinctStrings("TabTeachers", "UserID", "Role", 2);
                }

                if (chkToSecretary.Checked)//找出辅导员ID
                {
                    strID2 = AddSQLStringToDAL.GetDistinctStrings("TabTeachers", "UserID", "Role", 3);
                }

                if (chkToTeacher.Checked)//找出所有有课教师的ID
                {
                    strID3 = AddSQLStringToDAL.GetDistinctStrings("Tabteachers", "UserID");
                }

                //将这三个找出来的全部放到strSum里
                strSum.AddRange(strID1);
                strSum.AddRange(strID2);
                strSum.AddRange(strID3);

                //因为有课的教师也可能是辅导员或者校领导,所以移除相同的ID
                for (int i = 0; i < strSum.Count; i++)
                {
                    for (int j = 0; j < strSum.Count; j++)
                    {
                        if (i != j)
                        {
                            if (strSum[i] == strSum[j])
                            {
                                strSum.RemoveAt(j);
                            }
                        }
                    }
                }


                if (strSum.Count > 0)
                {
                    for (int i = 0; i < strSum.Count; i++)
                    {
                        if (AddSQLStringToDAL.InsertTabTeachers("TabMessage", System.DateTime.Now.ToString(), txtxMessage.Text.ToString(), strSum[i].ToString(), "false", "", ""))
                        {
                        }
                    }
                    lblMessage.Text  = "消息发送成功!";
                    txtxMessage.Text = "";
                }
            }
        }
    }