コード例 #1
0
 protected void BtnDepartmentCount_Click(object sender, EventArgs e)
 {
     string[] str = { "会计系", "信息工程系", "经济管理系", "食品工程系", "机械工程系", "商务外语系", "建筑工程系" };
     int[]    sum = new int[str.Length];
     if (txtKJ.Text != "" && txtXX.Text != "" && txtJG.Text != "" && txtSP.Text != "")
     // && txtJX.Text != "" && txtWY.Text != "" && txtJZ.Text != ""
     {
         sum[0] = Convert.ToInt32(txtKJ.Text.Trim());
         sum[1] = Convert.ToInt32(txtXX.Text.Trim());
         sum[2] = Convert.ToInt32(txtJG.Text.Trim());
         sum[3] = Convert.ToInt32(txtSP.Text.Trim());
         //sum[4] = Convert.ToInt32(txtJX.Text.Trim());
         //sum[5] = Convert.ToInt32(txtWY.Text.Trim());
         //sum[6] = Convert.ToInt32(txtJZ.Text.Trim());
     }
     if (AddSQLStringToDAL.DeleteTabTeachers("TabDepartment"))
     {
         for (int i = 0; i < str.Length; i++)
         {
             string strSql = "INSERT INTO TabDepartment VALUES('" + str[i] + "','" + sum[i] + "')";
             if (AddSQLStringToDAL.InsertData(strSql))
             {
                 Label16.Text = "各系人数设置完毕";
             }
             else
             {
                 Label16.Text = "设置失败";
             }
         }
     }
 }
コード例 #2
0
    //删除
    protected void gvTeachers_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string strSql = "delete from TabTeachers where UserID='" + gvTeachers.DataKeys[e.RowIndex].Value.ToString() + "'";

        AddSQLStringToDAL.InsertData(strSql);
        Bind();
    }
コード例 #3
0
    //更改后提交发生
    protected void gvTeachers_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        DropDownList ddlSex      = (DropDownList)gvTeachers.Rows[e.RowIndex].Cells[4].FindControl("ddlTeacherRole");
        int          strUserRole = Convert.ToInt32(ddlSex.SelectedValue);
        //string strUserRole = ((DropDownList)(gvTeachers.Rows[e.RowIndex].Cells[4].Controls[0])).SelectedItem.Text.ToString().Trim();//用户权限
        string strUserID = gvTeachers.DataKeys[e.RowIndex].Value.ToString();
        string strSql    = "update TabTeachers set Role = " + strUserRole + " where UserID = '" + strUserID + "' ";

        AddSQLStringToDAL.InsertData(strSql);
        gvTeachers.EditIndex = -1;
        Bind();
    }
コード例 #4
0
 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         Button label = (Button)e.Item.FindControl("tabLab");
         if (label.Text.Equals("未读"))
         {
             string time = ((Label)e.Item.FindControl("timeLab")).Text;
             string UID  = Session["UserID"].ToString();
             string sql  = "UPDATE [TabMessage] SET[MessageStatus] = '已读' WHERE[MessageTime] = '" + time + "' and [UserID] = '" + UID + "'";
             AddSQLStringToDAL.InsertData(sql);
             label.Text = "已读";
         }
         else
         {
             label.Enabled = false;
         }
     }
 }
コード例 #5
0
    protected void btnOK_Click1(object sender, EventArgs e)
    {
        if (TextBox1.Text != "" && TextBox2.Text != "" && TextBox3.Text != "")
        {
            string sql         = "select * from TabTeachers where UserId = '" + TextBox1.Text.Trim() + "' ";
            string teacherType = "";
            string teacherRole = "";
            switch (ddlType.SelectedItem.ToString().Trim())
            {
            case "本校教师":
                teacherType = "TabTeachers";
                break;

            case "外聘教师":
                teacherType = "TabOtherTeachers";
                break;

            default:
                break;
            }
            switch (Convert.ToInt32(ddlDepartmentName.SelectedIndex))
            {
            case 0:
                teacherRole = "4";
                break;

            case 1:
                teacherRole = "3";
                break;

            case 2:
                teacherRole = "2";
                break;

            case 3:
                teacherRole = "1";
                break;

            default:
                break;
            }
            try

            {
                string    strSql = "insert into " + teacherType + "(Department,UserID,UserPWD,UserName) values ('" + ddlDepartmentName.SelectedItem + "','" + TextBox1.Text + "','" + TextBox3.Text + "','" + TextBox2.Text + "')";
                DataTable dt     = AddSQLStringToDAL.GetDtBySQL(sql);

                Regex reg = new Regex("[0-9]{10}"); //判断是不是数据,要不是就表示没有选择,则从隐藏域里读出来
                Match ma  = reg.Match(TextBox1.Text.Trim());
                if (ma.Success)
                {
                    //是数字时的操作

                    if (dt.Rows.Count == 0)
                    {
                        if (TextBox3.Text.Trim().Length >= 6 && TextBox3.Text.Trim().Length <= 16)
                        {
                            if (AddSQLStringToDAL.InsertData(strSql))
                            {
                                Clear();
                                Response.Write("<script type='text/javascript'>alert('添加成功')</script>");
                            }
                            else
                            {
                                Response.Write("<script type='text/javascript'>alert('添加失败')</script>");
                            }
                        }
                        else
                        {
                            Response.Write("<script type='text/javascript'>alert('请输入密码')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script type='text/javascript'>alert('已存在该教师')</script>");
                    }
                }

                else
                {
                    Response.Write("<script type='text/javascript'>alert('教师工号须10位数字')</script>");
                }
            }
            catch
            {
                Clear();
                Response.Write("<script type='text/javascript'>alert('输入有误!请核对教师工号等信息!教师工号不能重复!')</script>");
            }
        }
        else
        {
            Response.Write("<script type='text/javascript'>alert('输入有误!请核对教师工号等信息!教师工号不能重复!')</script>");
        }
    }
コード例 #6
0
    protected void Button1_Click1(object sender, EventArgs e)
    {
        if (TextBox1.Text.Equals(""))
        {
            return;
        }
        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 (CheckBox1.Checked == true)
        {
            strID1 = AddSQLStringToDAL.GetDistinctString("TabTeachers", "UserID", "Role", "2");
        }
        if (CheckBox2.Checked == true)
        {
            strID2 = AddSQLStringToDAL.GetDistinctString("TabTeachers", "UserID", "Role", "3");
        }
        if (CheckBox3.Checked == true)
        {
            strID3 = AddSQLStringToDAL.GetDistinctString("TabTeachers", "UserID", "Role", "4");
        }
        strSum.AddRange(strID1);
        strSum.AddRange(strID2);
        strSum.AddRange(strID3);

        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.InsertData("insert into TabMessage([Message],[UserID],[MessageStatus]) values('" + TextBox1.Text + "','" + strSum[i] + "','未读')"))
                {
                    Label6.Text = "信息发送成功!";
                }
                else
                {
                    Label6.Text = "信息发送失败!";
                }
            }
            TextBox1.Text = "";
        }
        else
        {
            Label6.Text = "没有选择发送单位";
        }
    }
コード例 #7
0
    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 = MakeTabStudentAttendance();

        attendanceList.Clear();
        int sum = 0;

        foreach (GridViewRow row in this.gvAttendanceDetails.Rows)
        {
            DataRow attendanceRow = attendanceList.NewRow();

            Control             ctl2 = row.FindControl("rdoLate");
            Control             ctl3 = row.FindControl("rdoAbsence");
            Control             ctl4 = row.FindControl("rdoEarly");
            Control             ctl5 = row.FindControl("rdoLeave");
            TableCellCollection cell = row.Cells;            //获取GridView本行中的值的集合
            if ((ctl2 as RadioButton).Checked)               //ctl2被选中 迟到
            {
                attendanceRow[0]  = Session["UserID"];       //TeacherID;
                attendanceRow[1]  = Session["UserName"];     //TeacherName
                attendanceRow[2]  = Session["CourseName"];   //CourseName 课程名
                attendanceRow[3]  = Session["CurrentWeek"];  //CourseAllWeek
                attendanceRow[4]  = Session["CourseWeek"];   //CourseWeek
                attendanceRow[5]  = Session["CourseTime"];   //CourseTime
                attendanceRow[6]  = cell[0].Text.ToString(); //StudentDepartment
                attendanceRow[7]  = cell[2].Text.ToString(); //StudentId
                attendanceRow[8]  = cell[3].Text.ToString(); //studentName
                attendanceRow[9]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[10] = "迟到";                    //AttendanceType
                attendanceList.Rows.Add(attendanceRow);
                sum++;
                strLate.Append(cell[3].Text.ToString() + ";");//学生姓名
            }
            if ((ctl3 as RadioButton).Checked)
            {
                attendanceRow[0]  = Session["UserID"];       //TeacherID;
                attendanceRow[1]  = Session["UserName"];     //TeacherName
                attendanceRow[2]  = Session["CourseName"];   //CourseName 课程名
                attendanceRow[3]  = Session["CurrentWeek"];  //CourseAllWeek
                attendanceRow[4]  = Session["CourseWeek"];   //CourseWeek
                attendanceRow[5]  = Session["CourseTime"];   //CourseTime
                attendanceRow[6]  = cell[0].Text.ToString(); //StudentDepartment
                attendanceRow[7]  = cell[2].Text.ToString(); //StudentId
                attendanceRow[8]  = cell[3].Text.ToString(); //studentName
                attendanceRow[9]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[10] = "旷课";                    //AttendanceType
                attendanceList.Rows.Add(attendanceRow);
                sum++;

                strAbsence.Append(cell[3].Text.ToString() + ";");
            }
            if ((ctl4 as RadioButton).Checked)
            {
                attendanceRow[0]  = Session["UserID"];       //TeacherID;
                attendanceRow[1]  = Session["UserName"];     //TeacherName
                attendanceRow[2]  = Session["CourseName"];   //CourseName 课程名
                attendanceRow[3]  = Session["CurrentWeek"];  //CourseAllWeek
                attendanceRow[4]  = Session["CourseWeek"];   //CourseWeek
                attendanceRow[5]  = Session["CourseTime"];   //CourseTime
                attendanceRow[6]  = cell[0].Text.ToString(); //StudentDepartment
                attendanceRow[7]  = cell[2].Text.ToString(); //StudentId
                attendanceRow[8]  = cell[3].Text.ToString(); //studentName
                attendanceRow[9]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[10] = "早退";                    //AttendanceType
                attendanceList.Rows.Add(attendanceRow);
                sum++;
                strEarly.Append(cell[3].Text.ToString() + ";");
            }
            if ((ctl5 as RadioButton).Checked)
            {
                attendanceRow[0]  = Session["UserID"];       //TeacherID;
                attendanceRow[1]  = Session["UserName"];     //TeacherName
                attendanceRow[2]  = Session["CourseName"];   //CourseName 课程名
                attendanceRow[3]  = Session["CurrentWeek"];  //CourseAllWeek
                attendanceRow[4]  = Session["CourseWeek"];   //CourseWeek
                attendanceRow[5]  = Session["CourseTime"];   //CourseTime
                attendanceRow[6]  = cell[0].Text.ToString(); //StudentDepartment
                attendanceRow[7]  = cell[2].Text.ToString(); //StudentId
                attendanceRow[8]  = cell[3].Text.ToString(); //studentName
                attendanceRow[9]  = cell[1].Text.ToString(); //t4 班级名称
                attendanceRow[10] = "请假";                    //AttendanceType
                attendanceList.Rows.Add(attendanceRow);
                sum++;
                strLeave.Append(cell[3].Text.ToString() + ";");
            }
        }
        string result = AddSQLStringToDAL.InsertForSql(attendanceList, "TabStudentAttendance", 11);//异常学生导入
        string strsql = "update TabTeacherCourseWeek SET AttendanceInfo = '已考勤' WHERE TeacherId = '" + Session["UserID"] + "' and CourseAllWeek = '" + Session["CurrentWeek"] + "' and CourseWeek = '" + Session["CourseWeek"] + "' and CourseTime = '" + Session["CourseTime"] + "'";

        AddSQLStringToDAL.InsertData(strsql);
        if (result == "导入成功")
        {
            if (strLate.ToString() == "迟到名单:")
            {
                strLate.Append("无");
            }
            if (strEarly.ToString() == "早退名单:")
            {
                strEarly.Append("无");
            }
            if (strAbsence.ToString() == "旷课名单:")
            {
                strAbsence.Append("无");
            }
            if (strLeave.ToString() == "请假名单:")
            {
                strLeave.Append("无");
            }

            lblAttendanceMessage.Text = strAbsence.ToString();
            lblLateMessage.Text       = strLate.ToString();
            lblEarlyMessage.Text      = strEarly.ToString();
            lblLeaveMessage.Text      = strLeave.ToString();
            strLate.Remove(0, strLate.Length);
            strAbsence.Remove(0, strAbsence.Length);
            strEarly.Remove(0, strEarly.Length);
            strLeave.Remove(0, strLeave.Length);

            SetControlsVisibleFalse();
            lblResultMessage.Text = "本次考勤记录已经上报成功!请返回主界面!";
            btnClose.Visible      = true;
        }
    }