コード例 #1
0
    /// <summary>
    /// 所选班级查询显示
    /// </summary>
    /// <param name="schoolid"></param>
    public void Select(int schoolid)
    {
        string departmentId = hidselect.Text.TrimEnd(',');

        if (!string.IsNullOrEmpty(departmentId))
        {
            DataSet ds = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentDataset(departmentId, schoolid);
            if (ds != null)
            {
                rptclass.DataSource = ds;
                rptclass.DataBind();
            }
        }
        if (ddlname.Items != null && ddlname.Items.Count > 0)
        {
            int userid = int.Parse(ddlname.SelectedValue);
            Exam.Entity.tb_User_DepartmentEntity model = Exam.BLL.tb_User_DepartmentBLL.GetInstance().GetAdminByUserId(userid);
            if (model != null)
            {
                hidclassid.Text = model.DepartmentId;
            }
            else
            {
                hidclassid.Text = "";
            }
        }
    }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //教师集合
         IList <Exam.Entity.tb_UserEntity> list = Exam.BLL.tb_UserBLL.GetInstance().GetNameBySchoolIdRoleId(identity._schoolID, 2);
         if (list.Count > 0 && list != null)
         {
             ddlname.DataSource     = list;
             ddlname.DataTextField  = "RealName";
             ddlname.DataValueField = "userid";
             ddlname.DataBind();
         }
         //判断当前选中教师是否为空
         if (ddlname.Items != null && ddlname.Items.Count > 0)
         {
             int userid = int.Parse(ddlname.SelectedValue);
             Exam.Entity.tb_User_DepartmentEntity model = Exam.BLL.tb_User_DepartmentBLL.GetInstance().GetAdminByUserId(userid);//查找当前教师所教班级
             if (model != null)
             {
                 hidclassid.Text = model.DepartmentId;
                 string  str = model.DepartmentId;
                 DataSet ds  = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentDatasetByDepartmentId(str, identity._schoolID);//根据班级id显示当班级
                 rptclass.DataSource = ds;
                 rptclass.DataBind();
             }
         }
     }
 }
コード例 #3
0
    //保存
    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = hidclassid.Text.Trim();//所教班级

        str = str.TrimStart(',');
        str = str.TrimEnd(',');
        if (ddlname.Items != null && ddlname.Items.Count > 0)
        {
            int userId = int.Parse(ddlname.SelectedValue);
            try
            {
                //如果有修改
                Exam.Entity.tb_User_DepartmentEntity tmodel = Exam.BLL.tb_User_DepartmentBLL.GetInstance().GetAdminByUserId(userId);
                if (tmodel != null)
                {
                    //为空时,不给TA任何班级,清除数据
                    if (str == string.Empty)
                    {
                        Exam.BLL.tb_User_DepartmentBLL.GetInstance().Delete(tmodel.RelationId);
                    }
                    else
                    {
                        tmodel.DepartmentId = str;
                        Exam.BLL.tb_User_DepartmentBLL.GetInstance().Update(tmodel);
                    }
                }
                else
                {
                    Exam.Entity.tb_User_DepartmentEntity model = new Exam.Entity.tb_User_DepartmentEntity();
                    model.SchoolId     = identity._schoolID;
                    model.UserId       = userId;
                    model.DepartmentId = str;
                    Exam.BLL.tb_User_DepartmentBLL.GetInstance().Insert(model);
                }
                Select(identity._schoolID);
                MessageBox.ShowMsg(this, "保存成功!");
            }
            catch (Exception ex)
            {
                MessageBox.ShowMsg(this, ex.ToString());
            }
        }
        else
        {
            MessageBox.ShowMsg(this, "暂无教师!");
        }
    }
コード例 #4
0
ファイル: AddDepartment.aspx.cs プロジェクト: Hizcy/exam
    protected void listMent_SelectedIndexChanged(object sender, EventArgs e)
    {
        hid1.Text = listMent.SelectedItem.Text;
        hid2.Text = listMent.SelectedValue;
        UserIdentity identity = User.Identity as UserIdentity;
        int          parentid = int.Parse(listMent.SelectedValue.ToString());

        if (identity != null)
        {
            //管理员and超级管理员
            if (identity._roleID == 1 || identity._roleID == 4 || identity._roleID == 5)
            {
                IList <Exam.Entity.tb_DepartmentEntity> list = Exam.BLL.tb_DepartmentBLL.GetInstance().Gettb_DepartmentParentIdList(parentid);
                listMent2.Items.Clear();
                listMent3.Items.Clear();
                if (list.Count > 0 && list != null)
                {
                    listMent2.DataSource     = list;
                    listMent2.DataTextField  = "name";
                    listMent2.DataValueField = "departmentid";
                    listMent2.DataBind();
                }
            }
            //教师
            else if (identity._roleID == 2)
            {
                listMent2.Items.Clear();
                listMent3.Items.Clear();
                Exam.Entity.tb_User_DepartmentEntity tmodel = Exam.BLL.tb_User_DepartmentBLL.GetInstance().GetAdminByUserId(identity.UserID);
                if (tmodel != null)
                {
                    DataSet ds = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentDatasetId(tmodel.DepartmentId, identity._schoolID);
                    if (ds != null)
                    {
                        listMent2.DataSource     = ds;
                        listMent2.DataTextField  = "parentname";
                        listMent2.DataValueField = "parentid";
                        listMent2.DataBind();
                    }
                }
            }
        }
    }
コード例 #5
0
 protected void ddlname_SelectedIndexChanged(object sender, EventArgs e)
 {
     hidname.Text        = "";
     rptclass.DataSource = string.Empty;
     rptclass.DataBind();
     if (ddlname.Items != null && ddlname.Items.Count > 0)
     {
         int userid = int.Parse(ddlname.SelectedValue);
         Exam.Entity.tb_User_DepartmentEntity model = Exam.BLL.tb_User_DepartmentBLL.GetInstance().GetAdminByUserId(userid);
         if (model != null)
         {
             hidclassid.Text = model.DepartmentId;
             string  str = model.DepartmentId;
             DataSet ds  = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentDatasetByDepartmentId(str, identity._schoolID);
             rptclass.DataSource = ds;
             rptclass.DataBind();
         }
     }
 }
コード例 #6
0
    private void BindData()
    {
        if (identity != null)
        {
            string where = "";
            //教师登录
            if (identity._roleID == 2)
            {
                Exam.Entity.tb_User_DepartmentEntity model = Exam.BLL.tb_User_DepartmentBLL.GetInstance().GetAdminByUserId(identity.UserID);
                if (model != null)
                {
                    string departmentid = model.DepartmentId;
                    where = " and departmentId in(" + departmentid + ")";
                    string partmentid = hiddepartmentId.Text.Trim();
                    if (!string.IsNullOrEmpty(partmentid))
                    {
                        where = " and CHARINDEX('/" + partmentid + "/',path)>0 ";
                        labdepartment.Text = hiddepartmentName.Text.Trim();
                    }
                    if (this.ddlsex.SelectedValue != "")
                    {
                        where += " and sex=" + ddlsex.SelectedValue;
                    }
                    if (this.ddlstatus.SelectedValue != "")
                    {
                        where += " and status=" + ddlstatus.SelectedValue;
                    }
                    int allCount;
                    int CurrentPage = 0;
                    CurrentPage = this.pager1.CurrentPageIndex;
                    DataSet ds = tb_UserBLL.GetInstance().GetListUser(pager1.PageSize, CurrentPage, "schoolid=" + identity._schoolID + where, out allCount);
                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        rptResultsList.DataSource = ds;
                        rptResultsList.DataBind();

                        pager1.RecordCount      = allCount;
                        pager1.CurrentPageIndex = CurrentPage;
                        i = 2;
                    }
                    else
                    {
                        rptResultsList.DataSource = string.Empty;
                        rptResultsList.DataBind();
                    }
                }
            }
            //管理员登录
            else if (identity._roleID == 1)
            {
                string partmentid = hiddepartmentId.Text.Trim();
                if (!string.IsNullOrEmpty(partmentid))
                {
                    where = " and CHARINDEX('/" + partmentid + "/',path)>0 ";
                    labdepartment.Text = hiddepartmentName.Text.Trim();
                }
                if (this.ddlsex.SelectedValue != "")
                {
                    where += " and sex=" + ddlsex.SelectedValue;
                }
                if (this.ddlstatus.SelectedValue != "")
                {
                    where += " and status=" + ddlstatus.SelectedValue;
                }
                int allCount;
                int CurrentPage = 0;
                CurrentPage = this.pager1.CurrentPageIndex;
                DataSet ds = tb_UserBLL.GetInstance().GetListUser(pager1.PageSize, CurrentPage, "schoolid=" + identity._schoolID + where, out allCount);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    rptResultsList.DataSource = ds;
                    rptResultsList.DataBind();
                    pager1.RecordCount      = allCount;
                    pager1.CurrentPageIndex = CurrentPage;
                    i = 2;
                }
                else
                {
                    rptResultsList.DataSource = string.Empty;
                    rptResultsList.DataBind();
                }
            }
            //超级管理员
            else if (identity._roleID == 4)
            {
                //部门选择
                string partmentid = hiddepartmentId.Text.Trim();
                if (!string.IsNullOrEmpty(partmentid))
                {
                    where = " and CHARINDEX('/" + partmentid + "/',path)>0 ";
                    labdepartment.Text = hiddepartmentName.Text.Trim();
                }
                if (this.ddlsex.SelectedValue != "")
                {
                    where += " and sex=" + ddlsex.SelectedValue;
                }
                if (this.ddlstatus.SelectedValue != "")
                {
                    where += " and status=" + ddlstatus.SelectedValue;
                }
                int allCount;
                int CurrentPage = 0;
                CurrentPage = this.pager1.CurrentPageIndex;
                DataSet ds = tb_UserBLL.GetInstance().GetListUser(pager1.PageSize, CurrentPage, " 1=1 " + where, out allCount);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    rptResultsList.DataSource = ds;
                    rptResultsList.DataBind();

                    pager1.RecordCount      = allCount;
                    pager1.CurrentPageIndex = CurrentPage;
                    i = 2;
                }
                else
                {
                    rptResultsList.DataSource = string.Empty;
                    rptResultsList.DataBind();
                }
            }
        }
    }