예제 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        lbl_fankui.Text = "";
        string banjiid         = ddl_banji.SelectedValue;
        string kechengid       = ddl_kecheng.SelectedValue;
        string tusername       = ddl_teacher.SelectedValue;
        string kechengname     = ddl_kecheng.SelectedItem.Text;
        string banjiname       = ddl_banji.SelectedItem.Text;
        string txingming       = ddl_teacher.SelectedItem.Text;
        string teacherusername = RenkeInfo.GetTeacherusername(kechengid, banjiid);

        if (teacherusername != string.Empty)
        {
            lbl_fankui.Text = "该课程已由" + TeacherInfo.TeacherXingMing(teacherusername) + "担任,添加任课信息失败!";
        }
        else
        {
            string         sqltxt = "insert into tb_teacherrenke(teacherusername,banjiid,kechengid,begintime) values(@tusername,@banjiid,@kechengid,@begintime)";
            SqlParameter[] pa     = new SqlParameter[4];
            pa[0] = new SqlParameter("@tusername", tusername);
            pa[1] = new SqlParameter("@banjiid", banjiid);
            pa[2] = new SqlParameter("@kechengid", kechengid);
            pa[3] = new SqlParameter("@begintime", DateTime.Now.ToString());
            if (SqlHelper.ExecuteNonQuery(SqlDal.conn, CommandType.Text, sqltxt, pa) > 0)
            {
                lbl_fankui.Text = banjiname + "的课程:" + kechengname + "由教师:" + txingming + "担任,添加成功!";
            }
            else
            {
                lbl_fankui.Text = banjiname + "的课程:" + kechengname + "由教师:" + txingming + "担任,添加失败!";
            }
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        string username = ((FormsIdentity)HttpContext.Current.User.Identity).Ticket.Name;

        if (Session["kechengid"] == null)
        {
            int minkechengid = TeacherInfo.GetTeacherRenke_min_kechengid(username);
            if (minkechengid > 0)
            {
                Session["kechengid"] = minkechengid;
            }
            else if (KechengInfo.GetKechengCount() > 0)
            {
                Session["kechengid"] = KechengInfo.MinKechengid();
            }
            else
            {
                List <string> noneKechengPage = new List <string>();//不需要课程的页面
                noneKechengPage.Add("createcourse.aspx");
                noneKechengPage.Add("help.aspx");
                noneKechengPage.Add("addbanji.aspx");
                noneKechengPage.Add("default.aspx");
                noneKechengPage.Add("studentdaoru.aspx");
                noneKechengPage.Add("wanshanxinxi.aspx");
                noneKechengPage.Add("addstudent.aspx");
                noneKechengPage.Add("editstudent.aspx");
                noneKechengPage.Add("editstudentinfo.aspx");
                noneKechengPage.Add("gerenxinxi.aspx");
                noneKechengPage.Add("kcxianyou.aspx");
                string url     = HttpContext.Current.Request.Url.AbsolutePath;
                string pageurl = url.Substring(url.LastIndexOf("/") + 1).ToLower();
                if (!noneKechengPage.Contains(pageurl))
                {
                    Response.Redirect("createcourse.aspx");
                }
            }
        }
        if (!IsPostBack)
        {
            Literal2.Text = TeacherInfo.TeacherXingMing(username) + "老师.";
            if (Session["kechengid"] != null)
            {
                lbl_kecheng.Text = KechengInfo.getKechengname(DropDownList1.SelectedValue = Session["kechengid"].ToString());
            }
            else
            {
                lbl_kecheng.Text = "未知";
            }
            lbtn_qiehuan.Visible = TeacherInfo.IsManager(username);//是否显示身份切换链接
        }
    }