Beispiel #1
0
        public Book.Model.T_Base_Admin check(String LoginName, String PWD)
        {
            SqlConnection co = new SqlConnection();

            co.ConnectionString = connstring;
            co.Open();

            SqlCommand cm = new SqlCommand();

            cm.Connection  = co;
            cm.CommandText = "select * from T_Base_Admin where LoginName = @LoginName and PWD = @PWD";
            cm.Parameters.AddWithValue("@LoginName", LoginName);
            cm.Parameters.AddWithValue("@PWD", PWD);
            SqlDataReader dr = cm.ExecuteReader();

            Book.Model.T_Base_Admin admin = new Model.T_Base_Admin();
            admin.LoginName = "-1";
            admin.PWD       = "-1";
            while (dr.Read())
            {
                admin.LoginName = Convert.ToString(dr["LoginName"]);
                admin.PWD       = Convert.ToString(dr["PWD"]);
                admin.RoleId    = Convert.ToInt32(dr["RoleId"]);
            }

            dr.Close();
            co.Close();
            return(admin);
        }
Beispiel #2
0
        public Book.Model.T_Base_Admin GetModal(int Id)
        {
            SqlConnection co = new SqlConnection();

            co.ConnectionString = "server=10.132.239.3;uid=sa;pwd=Jsj123456;database=15211160113";
            co.Open();
            SqlCommand cm = new SqlCommand();

            cm.Connection  = co;
            cm.CommandText = "select * from V_Role_Admin where Id=@Id";
            cm.Parameters.AddWithValue("@Id", Id);

            SqlDataReader dr = cm.ExecuteReader();

            Book.Model.T_Base_Admin item = new Model.T_Base_Admin();
            while (dr.Read())
            {
                item.Id        = Convert.ToInt32(dr["Id"]);
                item.LoginName = Convert.ToString(dr["LoginName"]);
                item.PWD       = Convert.ToString(dr["PWD"]);
                item.RoleName  = Convert.ToString(dr["RoleName"]);
                item.RoleId    = Convert.ToInt32(dr["RoleId"]);
            }
            dr.Close();
            co.Close();
            return(item);
        }
Beispiel #3
0
        public List <Model.T_Base_Admin> GetSearch(string Name, int matchCount)
        {
            //throw new NotImplementedException();
            SqlConnection co = new SqlConnection();

            co.ConnectionString = "server=10.132.239.3;uid=sa;pwd=Jsj123456;database=15211160113";
            co.Open();
            SqlCommand cm = new SqlCommand();

            cm.Connection  = co;
            cm.CommandText = "select top " + matchCount + " * from T_Base_Role where RoleName like '%" + Name + "%'";
            SqlDataReader dr = cm.ExecuteReader();
            List <Book.Model.T_Base_Admin> lst = new List <Model.T_Base_Admin>();

            while (dr.Read())
            {
                Book.Model.T_Base_Admin item = new Model.T_Base_Admin();
                //item.Id = Convert.ToInt32(dr["Id"]);
                //item.LoginName = Convert.ToString(dr["LoginName"]);
                //item.PWD = Convert.ToString(dr["PWD"]);
                item.RoleName = Convert.ToString(dr["RoleName"]);
                item.RoleId   = Convert.ToInt32(dr["Id"]);
                lst.Add(item);
            }
            dr.Close();
            co.Close();
            return(lst);
        }
Beispiel #4
0
        public List <Book.Model.T_Base_Admin> GetList(int currentPage, int pageSize, String Name = "")
        {
            SqlConnection co = new SqlConnection();

            co.ConnectionString = "server=10.132.239.3;uid=sa;pwd=Jsj123456;database=15211160113";
            co.Open();
            SqlCommand cm = new SqlCommand();

            cm.Connection  = co;
            cm.CommandText = "select top " + pageSize + " * from v_role_admin where id not in (select top " + pageSize * (currentPage - 1) + " id from v_role_admin where LoginName like '%" + Name + "%') and LoginName like '%" + Name + "%'";

            SqlDataReader dr = cm.ExecuteReader();
            List <Book.Model.T_Base_Admin> lst = new List <Model.T_Base_Admin>();

            while (dr.Read())
            {
                Book.Model.T_Base_Admin item = new Model.T_Base_Admin();
                item.Id        = Convert.ToInt32(dr["Id"]);
                item.LoginName = Convert.ToString(dr["LoginName"]);
                item.PWD       = Convert.ToString(dr["PWD"]);
                item.RoleName  = Convert.ToString(dr["RoleName"]);
                item.RoleId    = Convert.ToInt32(dr["RoleId"]);
                lst.Add(item);
            }
            dr.Close();
            co.Close();
            return(lst);
        }
Beispiel #5
0
 public ActionResult AddSave(string LoginName, string PWD, int RoleId)
 {
     Book.Model.T_Base_Admin Admin = new Model.T_Base_Admin();
     Admin.LoginName = LoginName;
     Admin.PWD       = PWD;
     Admin.RoleId    = RoleId;
     Book.BLL.T_Base_Admin bll = new BLL.T_Base_Admin();
     bll.Add(Admin);
     return(Redirect("Index"));
 }
        public Model.T_Base_Admin GetAdmin(string Admin)
        {
            SqlConfig  config = new SqlConfig();
            SqlCommand cmd    = config.getSqlCommand();

            Model.T_Base_Admin admin = new Model.T_Base_Admin();
            cmd.CommandText = "select * from T_Base_Admin where Admin = " + Admin;
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            admin.Id       = Convert.ToInt32(reader["Id"]);
            admin.Admin    = Convert.ToString(reader["Admin"]);
            admin.PassWord = Convert.ToString(reader["PassWord"]);
            admin.Role     = Convert.ToInt32(reader["Role"]);
            config.Close();
            return(admin);
        }
        public JsonResult LoginCheck(string Name, string password, string checkres)
        {
            string pwd = MD5Class.UserMd5(password);

            if (checkres == "学生")
            {
                DAL.DALT_Base_Student dal     = new DAL.DALT_Base_Student();
                Model.T_Base_Student  student = dal.GetStu(Name);
                if (ifExist(Name, pwd, checkres))
                {
                    Session["UserName"] = student.Name;
                    Session["UserId"]   = student.Id;
                    Session["ClassId"]  = student.ClassId;

                    Session["UserLevel"] = 0;
                    if (student.IsBGB == 1 && student.IsKDB == 1)
                    {
                        Session["UserLevel"] = 3;
                    }
                    else if (student.IsBGB == 1)
                    {
                        Session["UserLevel"] = 2;
                    }
                    else if (student.IsKDB == 1)
                    {
                        Session["UserLevel"] = 1;
                    }


                    return(Json(new { code = 11, message = "登录成功" }, JsonRequestBehavior.AllowGet));
                }

                else
                {
                    return(Json(new { code = 3, message = "用户名或密码错误" }, JsonRequestBehavior.AllowGet));
                }
            }
            else if (checkres == "老师")
            {
                DAL.DALT_Base_Teacher dal     = new DAL.DALT_Base_Teacher();
                Model.T_Base_Teacher  teacher = dal.GetTea(Name);
                DAL.DALT_Base_Class   dal2    = new DAL.DALT_Base_Class();
                Model.T_Base_Class    cla     = new T_Base_Class();

                if (teacher.IsBZR == 1)
                {
                    cla = dal2.FindCla(teacher.Id);
                    Session["ClassId"] = cla.Id;
                }
                else
                {
                    Session["ClassId"] = 0;
                }

                if (ifExist(Name, pwd, checkres))
                {
                    Session["UserName"] = teacher.Name;
                    Session["UserId"]   = teacher.Id;

                    Session["UserLevel"] = 10;
                    if (teacher.IsBZR == 1)
                    {
                        Session["UserLevel"] = 11;
                    }

                    return(Json(new { code = 12, message = "登录成功" }, JsonRequestBehavior.AllowGet));
                }

                else
                {
                    return(Json(new { code = 3, message = "用户名或密码错误" }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                DAL.DALT_Base_Admin dal   = new DAL.DALT_Base_Admin();
                Model.T_Base_Admin  admin = dal.GetAdmin(Name);
                if (ifExist(Name, pwd, checkres))
                {
                    Session["UserId"] = admin.Id;
                    Session["Name"]   = admin.LoginName;
                    return(Json(new { code = 13, message = "登录成功" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { code = 3, message = "用户名或密码错误" }, JsonRequestBehavior.AllowGet));
                }
            }
        }