Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //            Response.Write(@"[
            // {
            //    ""name"": ""55555"",
            //    ""value"": 1
            //  },
            //  {
            //    ""name"": ""44444"",
            //    ""value"": 5555
            //  }]

            //");

            czy_dbEntities      theEntity = new czy_dbEntities();
            IQueryable <object> rtv       =
                (from oneclass in theEntity.study_class
                 select new
            {
                value = oneclass.name,
                name = oneclass.id
            });

            JavaScriptSerializer jss = new JavaScriptSerializer();
            string jsonstr           = jss.Serialize(rtv.ToList());

            Response.Write(jsonstr);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string         username  = Request.Form["name"];
            string         password  = Request.Form["password"];
            czy_dbEntities theEntity = new czy_dbEntities();

            IQueryable <study_students> rtv =
                from oneStudent in theEntity.study_students
                where oneStudent.name.Equals(username) &&
                oneStudent.password.Equals(password)
                select oneStudent;

            if (rtv.Count() < 1)
            {
                //
            }
            else
            {
                Response.Redirect("index.aspx");
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "GET")
            {
                return;
            }
            string username = Request.Form["username"];
            string sex      = Request.Form["sex"];

            string classnum = Request.Form["classnum"];

            bool?b_sex = null;

            if (!string.IsNullOrEmpty(sex))
            {
                if (sex == "女")
                {
                    b_sex = true;
                }
                else
                {
                    b_sex = false;
                }
            }
            czy_dbEntities theEntity      = new czy_dbEntities();
            String         firstbtn       = Request.Form["firstbtn"];
            String         prebtn         = Request.Form["prebtn"];
            String         nextbtn        = Request.Form["nextbtn"];
            String         endbtn         = Request.Form["endbtn"];
            String         gobtn          = Request.Form["gobtn"];
            String         currentpagebtn = Request.Form["currentpageindex"];


            int wantpage = 1;

            if (null != Request.Form["currentpageindex"])
            {
                wantpage = Int32.Parse(currentpagebtn);
            }

            int total =
                (from onestudent in theEntity.study_students
                 join oneclass in theEntity.study_class
                 on onestudent.class_id equals oneclass.id
                 select onestudent
                ).Count();


            int totalpage = total / 5;

            if (total % 5 != 0)
            {
                totalpage++;
            }
            totalpagecount = totalpage;
            if (!String.IsNullOrEmpty(firstbtn))
            {
                wantpage = 1;
            }
            else if (!String.IsNullOrEmpty(prebtn))
            {
                wantpage--;
                if (wantpage <= 0)
                {
                    wantpage = 1;
                }
            }
            else if (!String.IsNullOrEmpty(nextbtn))
            {
                wantpage++;
                if (wantpage > totalpage)
                {
                    wantpage = totalpage;
                }
            }
            else if (!String.IsNullOrEmpty(endbtn))
            {
                wantpage = totalpage;
            }
            else if (!String.IsNullOrEmpty(gobtn))
            {
                if (wantpage > totalpage)
                {
                    wantpage = totalpage;
                }
            }



            IQueryable <object> rtv =
                (from oneStudent in theEntity.study_students
                 join oneClass in theEntity.study_class
                 on oneStudent.class_id equals oneClass.id
                 where (string.IsNullOrEmpty(username) ? true : oneStudent.name.Equals(username)) &&
                 (b_sex.Equals(null) ? true : oneStudent.sex.Equals(b_sex.Value)) &&
                 (string.IsNullOrEmpty(classnum) ? true : oneClass.name.Equals(classnum))
                 select new
            {
                studentid = oneStudent.id,
                name = oneStudent.name,
                sex = oneStudent.sex,
                banji = oneClass.name,
            }).OrderBy(theKey => theKey.studentid).Skip((wantpage - 1) * 5).Take(5);

            ViewState["data"] = rtv.ToList();
            responsepageindex = wantpage;
        }