/// <summary>
    /// 检测是否已经考勤
    /// </summary>
    /// <returns></returns>
    private bool CheckIsRecords()
    {
        DataTable dt = AddSQLStringToDAL.GetDTBySQL("TabCourses", "Teacher_id", "Current_Week", "Course",
                                                    "Week", "Time", Session["userID"].ToString(), Session["currentWeek"].ToString(), Session["currentCourse"].ToString(),
                                                    Session["week"].ToString(), Session["time"].ToString());

        if (dt.Rows[0]["is_attendance"].ToString().Trim() == "未考勤")
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Exemple #2
0
    /// <summary>
    /// 处理校历,确定处于第几周
    /// </summary>
    private void CurrentWeek()
    {
        DataTable dt = AddSQLStringToDAL.GetDTBySQL("TabCalendar");

        foreach (DataRow dr in dt.Rows)
        {
            if (Convert.ToDateTime(dr[1]) < DateTime.Now && Convert.ToDateTime(dr[2]) > DateTime.Now)
            {
                string strWeek = dr[0].ToString();
                if (strWeek.Length == 1)
                {
                    strWeek = "0" + strWeek;
                }
                Session["currentWeek"] = strWeek;
            }
        }
    }
Exemple #3
0
    private void bindData()
    {
        DataTable dt = AddSQLStringToDAL.GetDT4Course("Teacher_id", "Current_Week", Session["userID"].ToString(), Session["currentWeek"].ToString());

        if (dt.Rows.Count == 0)
        {
            lbTitile.Text = "您本周无授课安排";
        }
        else
        {
            DataView dv = dt.DefaultView;
            dv.Sort = "week ASC,time";
            Repeater1.DataSource = dv.ToTable();
            Repeater1.DataBind();
        }

        //作业处理
        int weekNum = Convert.ToInt32(Session["currentWeek"].ToString()), lastWeek = 0;

        if (weekNum > 1)
        {
            lastWeek = weekNum - 1;
        }
        if (lastWeek != 0)
        {
            //TODO
            DataTable dtHome = AddSQLStringToDAL.GetDTBySQL("TabCourses", "Teacher_ID", "Current_Week", "Count", Session["userID"].ToString(), lastWeek.ToString(), "已布置作业");
            if (dtHome.Rows.Count == 0)
            {
                lbWork.Text = "上周作业没有未批改情况!";
            }
            else
            {
                Repeater2.DataSource = dtHome;
                Repeater2.DataBind();
            }
        }
    }
    /// <summary>
    /// 提交按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAtten_Click(object sender, EventArgs e)
    {
        StringBuilder strLate    = new StringBuilder("迟到名单:");
        StringBuilder strAbsence = new StringBuilder("旷课名单:");
        StringBuilder strEarly   = new StringBuilder("早退名单:");
        StringBuilder strLeave   = new StringBuilder("请假名单:");
        //获取表结构
        DataTable attendanceList = AddSQLStringToDAL.GetDTBySQL("TabStudentAttendance", "0", "1");
        //创建符合表结构的一行
        DataRow attendanceRow = attendanceList.NewRow();
        int     sum           = 0; //总人数

        foreach (GridViewRow row in this.GridView1.Rows)
        {
            //单选框属性对象
            Control             ctl2 = row.FindControl("RadioButton2");
            Control             ctl3 = row.FindControl("RadioButton3");
            Control             ctl4 = row.FindControl("RadioButton4");
            Control             ctl5 = row.FindControl("RadioButton5");
            TableCellCollection cell = row.Cells;//获取GridView本行中的值的集合
            if ((ctl2 as RadioButton).Checked)
            {
                attendanceRow[0]  = Session["userID"];
                attendanceRow[1]  = Session["userName"];
                attendanceRow[2]  = Session["course"];       //课程名
                attendanceRow[3]  = Session["currentWeek"];  // 周 数字
                attendanceRow[4]  = Session["week"];         // 周,格式化显示
                attendanceRow[5]  = Session["time"];         // 第几节
                attendanceRow[6]  = cell[0].Text.ToString(); //系部
                attendanceRow[7]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[8]  = cell[2].Text.ToString(); //Id
                attendanceRow[9]  = cell[3].Text.ToString(); //Name
                attendanceRow[10] = "迟到";
                attendanceRow[11] = cell[1].Text.ToString(); //t4 班级名称  并不知道啥用
                attendanceList.Rows.Add(attendanceRow);
                sum++;
                strLate.Append(cell[3].Text.ToString() + ";");
                attendanceRow = attendanceList.NewRow();
            }
            else
            if ((ctl3 as RadioButton).Checked)
            {
                attendanceRow[0]  = Session["userID"];
                attendanceRow[1]  = Session["userName"];
                attendanceRow[2]  = Session["course"];       //课程名
                attendanceRow[3]  = Session["currentWeek"];  // 周 数字
                attendanceRow[4]  = Session["week"];         // 周,格式化显示
                attendanceRow[5]  = Session["time"];         // 第几节
                attendanceRow[6]  = cell[0].Text.ToString(); //系部
                attendanceRow[7]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[8]  = cell[2].Text.ToString(); //Id
                attendanceRow[9]  = cell[3].Text.ToString(); //Name
                attendanceRow[10] = "旷课";
                attendanceRow[11] = cell[1].Text.ToString(); //t4 班级名称  并不知道啥用
                attendanceList.Rows.Add(attendanceRow);
                sum++;

                strAbsence.Append(cell[3].Text.ToString() + ";");
                attendanceRow = attendanceList.NewRow();
            }
            else
            if ((ctl4 as RadioButton).Checked)
            {
                attendanceRow[0]  = Session["userID"];
                attendanceRow[1]  = Session["userName"];
                attendanceRow[2]  = Session["course"];       //课程名
                attendanceRow[3]  = Session["currentWeek"];  // 周 数字
                attendanceRow[4]  = Session["week"];         // 周,格式化显示
                attendanceRow[5]  = Session["time"];         // 第几节
                attendanceRow[6]  = cell[0].Text.ToString(); //系部
                attendanceRow[7]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[8]  = cell[2].Text.ToString(); //Id
                attendanceRow[9]  = cell[3].Text.ToString(); //Name
                attendanceRow[10] = "早退";
                attendanceRow[11] = cell[1].Text.ToString(); //t4 班级名称  并不知道啥用
                attendanceList.Rows.Add(attendanceRow);
                sum++;

                strEarly.Append(cell[3].Text.ToString() + ";");
                attendanceRow = attendanceList.NewRow();
            }
            else
            if ((ctl5 as RadioButton).Checked)
            {
                attendanceRow[0]  = Session["userID"];
                attendanceRow[1]  = Session["userName"];
                attendanceRow[2]  = Session["course"];       //课程名
                attendanceRow[3]  = Session["currentWeek"];  // 周 数字
                attendanceRow[4]  = Session["week"];         // 周,格式化显示
                attendanceRow[5]  = Session["time"];         // 第几节
                attendanceRow[6]  = cell[0].Text.ToString(); //系部
                attendanceRow[7]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[8]  = cell[2].Text.ToString(); //Id
                attendanceRow[9]  = cell[3].Text.ToString(); //Name
                attendanceRow[10] = "请假";
                attendanceRow[11] = cell[1].Text.ToString(); //t4 班级名称  并不知道啥用
                attendanceList.Rows.Add(attendanceRow);
                sum++;

                strLeave.Append(cell[3].Text.ToString() + ";");
                attendanceRow = attendanceList.NewRow();
            }
        }
        if (!AddSQLStringToDAL.UpdateDT4Copy(attendanceList, "TabStudentAttendance"))
        {
            return;
        }

        //更新老师状态为已考勤
        bool isUpdate = AddSQLStringToDAL.UpdateRows("TabCourses", "is_attendance", "已考勤", "teacher_id", "Current_Week", "Course",
                                                     "Week", "Time", Session["userID"].ToString(), Session["currentWeek"].ToString(), Session["currentCourse"].ToString(),
                                                     Session["week"].ToString(), Session["time"].ToString());

        if (isUpdate)
        {
            if (strLate.ToString() == "迟到名单:")
            {
                strLate.Append("无");
            }
            if (strEarly.ToString() == "早退名单:")
            {
                strEarly.Append("无");
            }
            if (strAbsence.ToString() == "旷课名单:")
            {
                strAbsence.Append("无");
            }
            if (strLeave.ToString() == "请假名单:")
            {
                strLeave.Append("无");
            }

            Label2.Text = strAbsence.ToString();
            Label3.Text = strLate.ToString();
            Label4.Text = strEarly.ToString();
            Label5.Text = strLeave.ToString();
            //清空数据
            strLate.Clear();
            strAbsence.Clear();
            strEarly.Clear();
            strLeave.Clear();
            GridView1.Visible = false;
            btnAtten.Visible  = false;
            Label6.Text       = "本次考勤记录已经上报成功!本次课您" + Session["homeWork"].ToString() + ",请返回主界面!";
            btnClose.Visible  = true;
        }
    }
Exemple #5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (value_1.Text.Length != 0 && value_2.Text.Length != 0)
        {
            DataTable dt = AddSQLStringToDAL.GetDTBySQL("TabTeachers", "User_ID", "User_PWD", value_1.Text, BLL.Tools.PWDProcess.Encrypt(value_2.Text));
            if (dt.Rows.Count == 1)
            {
                string role = dt.Rows[0]["role"].ToString();
                Session["userID"] = value_1.Text.Trim();
                //保存用户数据
                Session["userName"] = dt.Rows[0]["User_Name"].ToString(); //去一下空格
                Session["readMsg"]  = dt.Rows[0]["read_msg"].ToString();
                CurrentWeek();

                switch (role)
                {
                case "1":
                    //页面跳转
                    Session["role"]        = "系统管理员";
                    Session["currentRole"] = "1";
                    Response.Redirect("./Admin/Default.aspx");
                    //Response.Redirect("./Admin/GetMessage.aspx");
                    break;

                case "2":
                    //页面跳转
                    Session["role"]        = "院系领导";
                    Session["currentRole"] = "2";
                    Response.Redirect("./Leader/Default.aspx");
                    break;

                case "3":
                    //页面跳转
                    Session["role"]        = "辅导员";
                    Session["currentRole"] = "3";
                    Response.Redirect("./Secretary/Default.aspx");
                    break;

                case "4":
                    //页面跳转
                    Session["role"]        = "教师";
                    Session["currentRole"] = "4";
                    Response.Redirect("./Teacher/Default.aspx");
                    break;

                default:
                    break;
                }
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = "用户名或密码错误!";
            }
        }
        else
        {
            Label1.Visible = true;
            Label1.Text    = "请完整填写用户名或密码";
        }
    }