Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         BindUserType();
         if (Request.QueryString["id"] != null)
         {
             int id = Convert.ToInt32(Request.QueryString["id"]);
             user = userBLL.GetModel(id);
             txtLoginName.Text = user.loginname;
             txtLoginName.Enabled = false;
             txtRealName.Text = user.realname;
             ddlUserType.Items.FindByValue(user.usertype.ToString()).Selected = true;
             ddlUserType.Enabled=false;
             if (user.usertype == 3)
             {
                 BindClass();
                 ddlClass.Items.FindByValue(user.classid.ToString()).Selected = true;
                 ddlClass.Enabled = true;
             }
             else
             {
                 ddlClass.Enabled = false;
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Model.tbUser> DataTableToList(DataTable dt)
        {
            List <Model.tbUser> modelList = new List <Model.tbUser>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Model.tbUser model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.tbUser();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.loginname = dt.Rows[n]["loginname"].ToString();
                    model.realname  = dt.Rows[n]["realname"].ToString();
                    model.userpwd   = dt.Rows[n]["userpwd"].ToString();
                    if (dt.Rows[n]["classid"].ToString() != "")
                    {
                        model.classid = int.Parse(dt.Rows[n]["classid"].ToString());
                    }
                    if (dt.Rows[n]["usertype"].ToString() != "")
                    {
                        model.usertype = int.Parse(dt.Rows[n]["usertype"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(hfPageIndex.Value))
     {
         pageIndex = Convert.ToInt32(hfPageIndex.Value);
     }
     if (!String.IsNullOrEmpty(hfPageSize.Value))
     {
         pageSize = Convert.ToInt32(hfPageSize.Value);
     }
     user=(tbUser)Session[Constant.User];
     if (!IsPostBack)
     {
         BindSubject();
         BindData();
     }
 }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        user = (tbUser)Session[Constant.User];

        if (!String.IsNullOrEmpty(hfPageIndex.Value))
        {
            pageIndex = Convert.ToInt32(hfPageIndex.Value);
        }
        if (!String.IsNullOrEmpty(hfPageSize.Value))
        {
            pageSize = Convert.ToInt32(hfPageSize.Value);
        }

        if (!IsPostBack)
        {
            BindData();

            Label1.Text = user.loginname;
            Label2.Text = user.realname;
            Label3.Text = DateTime.Now.ToString();
            Label4.Text = Request.UserHostAddress;

            lblRealName.Text = user.realname;
            switch (user.usertype)
            {                
                case 1: lblRole.Text = "管理员"; menu1.Visible = true; menu2.Visible = true; menu3.Visible = false;
                    menu4.Visible = false; menu5.Visible = false; menu6.Visible = false;
                    menu7.Visible = false; menu8.Visible = true; menu9.Visible = true;
                    Image1.ImageUrl = "~/images/admin.jpg"; break;
                case 2: lblRole.Text = "教师"; menu1.Visible = false; menu2.Visible = false; menu3.Visible = true;
                    menu4.Visible = true; menu5.Visible = true; menu6.Visible = true;
                    menu7.Visible = false; menu8.Visible = true; menu9.Visible = true;
                    Image1.ImageUrl = "~/images/tea.jpg"; break;
                case 3: lblRole.Text = "学生"; menu1.Visible = false; menu2.Visible = false; menu3.Visible = false;
                    menu4.Visible = false; menu5.Visible = false; menu6.Visible = false;
                    menu7.Visible = true; menu8.Visible = true; menu9.Visible = false;
                    Image1.ImageUrl = "~/images/stu.jpg"; break;
                case 4: lblRole.Text = "超级管理员"; menu1.Visible = true; menu2.Visible = true; menu3.Visible = false;
                    menu4.Visible = false; menu5.Visible = false; menu6.Visible = false;
                    menu7.Visible = false; menu8.Visible = true; menu9.Visible = true;
                    Image1.ImageUrl = "~/images/admin.jpg"; break;
            }
        }
    }
Пример #5
0
        /// <summary>
        /// 导入到数据库
        /// </summary>
        /// <param name="dt"></param>
        /// <returns>返回插入不成功的学号</returns>
        public static List<String> ExportToDB(DataTable dt)
        {
            List<String> list = new List<string>();
            tbUserDAL userDAL = new tbUserDAL();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                tbUser user = new tbUser();
                String loginname = dt.Rows[i][0].ToString();
                String realname = dt.Rows[i][1].ToString();
                String userpwd = dt.Rows[i][2].ToString();
                String classname = dt.Rows[i][3].ToString();
                String usertype = dt.Rows[i][4].ToString();

                user.loginname = loginname;//登陆名
                user.realname = realname;//真实名

                if (usertype.Trim() == "学生")
                {
                    if (IsNum(loginname))
                    {
                        //班级
                        try
                        {
                            int classid = (int)DbHelperSQL.GetSingle("select top 1 id from tbClass where classname=@classname", new SqlParameter("@classname", classname));
                            user.classid = classid;
                        }
                        catch (Exception)
                        {
                            list.Add("行" + (i + 2) + "的班级不存在!");
                            continue;
                        }
                    }
                    else
                    {
                        list.Add("行" + (i + 2) + "的学号格式不正确!");
                        continue;
                    }
                    user.usertype = 3;
                }
                else
                    if (usertype.Trim() == "教师")
                    {
                        user.usertype = 2;
                    }
                    else
                    {
                        list.Add("行" + (i + 2) + "的身份格式不正确!");
                        continue;
                    }
                //密码
                try
                {
                    user.userpwd = MyUtil.MD5(GetPwdByCard(userpwd));
                }
                catch (Exception)
                {
                    list.Add("行" + (i + 2) + "的密码格式不正确!");
                    continue;
                }

                //判断登陆名是否存在
                if (DbHelperSQL.Exists("select * from tbUser where loginname=@loginname", new SqlParameter("@loginname", loginname)))
                {
                    list.Add("行" + (i + 2) + "的登陆名已经存在!");
                    continue;
                }

                userDAL.Add(user);
            }
            return list;
        }
Пример #6
0
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.tbUser> DataTableToList(DataTable dt)
		{
			List<Model.tbUser> modelList = new List<Model.tbUser>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.tbUser model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.tbUser();					
													if(dt.Rows[n]["id"].ToString()!="")
				{
					model.id=int.Parse(dt.Rows[n]["id"].ToString());
				}
																																				model.loginname= dt.Rows[n]["loginname"].ToString();
																																model.realname= dt.Rows[n]["realname"].ToString();
																																model.userpwd= dt.Rows[n]["userpwd"].ToString();
																												if(dt.Rows[n]["classid"].ToString()!="")
				{
					model.classid=int.Parse(dt.Rows[n]["classid"].ToString());
				}
																																if(dt.Rows[n]["usertype"].ToString()!="")
				{
					model.usertype=int.Parse(dt.Rows[n]["usertype"].ToString());
				}
																										
				
					modelList.Add(model);
				}
			}
			return modelList;
		}
Пример #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.tbUser model)
 {
     return(dal.Update(model));
 }
Пример #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Model.tbUser model)
 {
     return(dal.Add(model));
 }