示例#1
0
    protected void BindToGridView(string strSql)
    {
        DataTable dt = AddSQLStringToDAL.GetDtBySQL(strSql);

        //dt.DefaultView.Sort =
        gvTeachers.DataSource   = dt;
        gvTeachers.DataKeyNames = new string[] { "UserID" };
        gvTeachers.DataBind();
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "当前在线" + Application["online"].ToString() + "人";
        Label2.Text = Session["UserName"].ToString()
                      + "你好,你的权限为" + Session["Role"].ToString();
        Label5.Text = "校历第" + Session["CurrentWeek"].ToString() + "周";
        string            sql = "SELECT [Message] FROM [TabMessage] WHERE UserID = '" + Session["UserID"] + "' and MessageStatus = 'False'";
        DataRowCollection drc = AddSQLStringToDAL.GetDtBySQL(sql).Rows;

        if (drc.Count != 0)
        {
            Label6.Text = drc[0][0].ToString();
        }
    }
示例#3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        // Button1.Attributes.Add("onclick", "validate()");
        string    strSQL = "select * from TabTeachers where UserID =" + userName.Text.Trim() + " and UserPWD=" + password.Text.ToString() + "";
        DataTable dt     = null;

        if (userName.Text != "" && password.Text != "")
        {
            dt = AddSQLStringToDAL.GetDtBySQL(strSQL);
            if (dt.Rows.Count == 1)
            {
                int Role = Convert.ToInt32(dt.Rows[0]["Role"]);
                Session["UserID"]   = userName.Text.Trim();
                Session["UserName"] = dt.Rows[0]["UserName"].ToString();
                Session["Role"]     = RoleString(Role);
                switch (Role)
                {
                case 1:
                    Response.Redirect("Admin\\AdminSubmitAttendance.aspx");
                    break;

                case 2:
                    Response.Redirect("Leader\\AdminSubmitAttendance.aspx");
                    break;

                case 3:
                    Response.Redirect("Secretary\\AdminSubmitAttendance.aspx");
                    break;

                case 4:
                    Response.Redirect("Teacher\\AdminSubmitAttendance.aspx");
                    break;

                default:
                    break;
                }
            }
            else
            {
                Response.Write("<script type='text/javascript'>alert('用户名或密码错误')</script>");
            }
        }
        else
        {
            Response.Write("<script type='text/javascript'>alert('请完善用户信息')</script>");
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     //IsPostBack 在第一次打开时是false
     if (!IsPostBack)
     {
         //第一次打开时执行
         string    sql = "select * from [TabTeacherCourseWeek] where [TeacherID] = " + Session["UserID"] + " and CourseAllWeek = " + Session["CurrentWeek"] + " ";
         DataTable dt  = AddSQLStringToDAL.GetDtBySQL(sql);
         this.thisRepeater.DataSource = dt;
         thisRepeater.DataBind();
         string    sql2 = "select * from [TabTeacherCourseWeek] where [TeacherID] = " + Session["UserID"] + " and CourseAllWeek = " + (Convert.ToInt32(Session["CurrentWeek"]) - 1) + " ";
         DataTable dt2  = AddSQLStringToDAL.GetDtBySQL(sql2);
         this.lastRepeater.DataSource = dt2;
         lastRepeater.DataBind();
     }
     else
     {
         //Response.Redirect("..\\Login.aspx");
     }
 }
    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
    private DataTable MakeTabStudentAttendance()
    {
        string strSql = "select * from [TabStudentAttendance] where 0 = 1";   //只获取表的结构

        return(AddSQLStringToDAL.GetDtBySQL(strSql));
    }