Ejemplo n.º 1
0
        public ActionResult GetAllBanJikaishekecheng(int?page, int?limit)
        {
            int PageIndex = page ?? 1;
            int PageSize  = limit ?? 20;
            int COUNT     = bll2.GetAll().Count();
            int Count;
            List <BanJiKaiSheKeChengJiHuaBiao> list2;

            if (Session["Teacher"] != null)
            {
                YuanGongBiao yuanGong = Session["Teacher"] as YuanGongBiao;
                list2 = bll2.GetPage(PageIndex, PageSize, out Count, yuanGong.ID.ToString());
            }
            else
            {
                XueShengBiao xueSheng = Session["Student"] as XueShengBiao;
                list2 = bll2.GetPage(PageIndex, PageSize, out Count, xueSheng.StudentClassID.Value);
            }
            var jsondata = new
            {
                code  = 0,
                msg   = "成功",
                count = Count,
                data  = list2
            };

            return(Json(jsondata, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public int AddStuClass1(int ID, int BjID)
        {
            XueShengBiao xs = context.Set <XueShengBiao>().Where(p => p.ID == ID).OrderByDescending(p => p.ID).First();
            BanJiBiao    bj = context.Set <BanJiBiao>().Where(p => p.ID == BjID).First();

            return(GetXsBj1(xs, bj));
        }
Ejemplo n.º 3
0
        //
        ////新增学生与班级关联表
        #region 增加关联表 学生-班级
        public int AddStuClass()
        {
            XueShengBiao xs = context.Set <XueShengBiao>().OrderByDescending(p => p.ID).First();
            BanJiBiao    bj = context.Set <BanJiBiao>().Where(p => p.ID == xs.StudentClassID).First();

            return(GetXsBj(xs, bj));
        }
Ejemplo n.º 4
0
        // 修改时,提交
        public ActionResult ZMEditAction(Student st)
        {
            XueShengBiao xs = new XueShengBiao();

            xs.StudentName = st.StudentName;
            xs.Age         = st.Age;
            xs.Address     = st.Address;
            xs.Phone       = st.Phone;
            xs.HomePhone   = st.HomePhone;
            xs.ID          = st.XID;
            if (st.Sex != true)
            {
                st.Sex = false;
            }
            xs.Sex = st.Sex;

            int n = xsb.UpdateXS(xs);

            if (n > 0)
            {
                return(Json(new { errorNo = "0", errorInfo = "执行修改成功" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { errorNo = "1", errorInfo = "执行错误,请检查重试" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 5
0
 public int UpdateXueSheng(XueShengBiao stu)
 {
     context.Set <XueShengBiao>().Attach(stu);
     context.Entry <XueShengBiao>(stu).State = EntityState.Modified;
     context.SaveChanges();
     return(1);
 }
Ejemplo n.º 6
0
        ////增加操作
        //增加学生时,做判断,判断学生添加所在班级是否满员
        //添加学生时防止同时添加多条信息
        public ActionResult ZMAddAction(Student st)
        {
            XueShengBiao xs = new XueShengBiao();

            xs.StudentName = st.StudentName;
            xs.Age         = st.Age;
            xs.Address     = st.Address;
            xs.Phone       = st.Phone;
            xs.HomePhone   = st.HomePhone;
            if (st.Sex != true)
            {
                st.Sex = false;
            }
            xs.Sex            = st.Sex;
            xs.MiMa           = "123456";
            xs.StudentClassID = Convert.ToInt16(st.BanJiMing);

            int n = xsb.Add(xs);

            if (n > 0)
            {
                return(Json(new { errorNo = "0", errorInfo = "执行成功" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { errorNo = "1", errorInfo = "执行错误,请检查重试" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 7
0
        public bool StuAdd(List <Models.XueShengBiao> exceles)
        {
            bool error = false;

            try
            {
                TransactionScope transaction = null;
                //因为每个章节只能出现一次,所以new一个new匿名类

                foreach (var item in exceles)
                {
                    XueShengBiao xs = new XueShengBiao();
                    xs.Address        = item.Address;
                    xs.Age            = item.Age;
                    xs.HomePhone      = item.HomePhone;
                    xs.MiMa           = item.MiMa;
                    xs.Phone          = item.Phone;
                    xs.StudentClassID = item.StudentClassID;
                    xs.Sex            = item.Sex;
                    xs.StudentName    = item.StudentName;
                    xs.ZhuangTai      = item.ZhuangTai;
                    mbll.StuAdd(xs);
                    mbll.AddStuClass();
                }
                error = true;
            }
            catch (Exception ex)
            {
                error = false;
                throw ex;
            }
            return(error);
        }
Ejemplo n.º 8
0
        public int Add(XueShengBiao xs)
        {
            int n = mbll.Add(xs);

            mbll.AddStuClass();
            return(n);
        }
Ejemplo n.º 9
0
        public int UpdateXS(XueShengBiao st)
        {
            List <SqlParameter> spls = new List <SqlParameter>();
            string       sql         = "update XueShengBiao Set StudentName = @name,Age = @age,Address = @addr,Phone= @p1,HomePhone = @p2  ";
            SqlParameter p1          = new SqlParameter("@name", st.StudentName);
            SqlParameter p2          = new SqlParameter("@age", st.Age);
            SqlParameter p3          = new SqlParameter("@addr", st.Address);
            SqlParameter p4          = new SqlParameter("@p1", st.Phone);
            SqlParameter p5          = new SqlParameter("@p2", st.HomePhone);

            spls.Add(p1);
            spls.Add(p2);
            spls.Add(p3);
            spls.Add(p4);
            spls.Add(p5);
            if (st.Sex != null)
            {
                sql += "  ,Sex = @sex  ";
                SqlParameter p6 = new SqlParameter("@sex", st.Sex);
                spls.Add(p6);
            }
            sql += "where ID = " + st.ID;

            int n = context.Database.ExecuteSqlCommand(sql, spls.ToArray());

            return(n);
        }
Ejemplo n.º 10
0
        public int TuiStu(int XID)
        {
            int          n  = mbll.TuiStu(XID);
            XueShengBiao xs = mbll.GetOne(XID);

            mbj.UpdateNum(xs, 1);
            return(n);
        }
Ejemplo n.º 11
0
        public int StuAdd(XueShengBiao xs)
        {
            MBanJiBiaoDAL bj = new MBanJiBiaoDAL();

            if (bj.UpdateNum(xs, 2) == 0)
            {
                return(0);
            }
            context.XueShengBiao.Add(xs);
            return(context.SaveChanges());
        }
Ejemplo n.º 12
0
        public int Delete(XueShengBiao st)
        {
            MBanJiBiaoDAL bj = new MBanJiBiaoDAL();

            if (bj.UpdateNum(st, 1) == 0)
            {
                return(0);
            }
            context.Set <XueShengBiao>().Attach(st);
            context.Set <XueShengBiao>().Remove(st);
            return(context.SaveChanges());
        }
Ejemplo n.º 13
0
        public int UpdateNum(XueShengBiao st, int i)
        {
            BanJiBiao bj = context1.Set <BanJiBiao>().Find(st.StudentClassID);

            if (i == 1)
            {
                bj.BanJiRenShu = bj.BanJiRenShu - 1;
            }
            else
            {
                bj.BanJiRenShu = bj.BanJiRenShu + 1;
            }
            return(Update1(bj));
        }
Ejemplo n.º 14
0
        public int GetXsBj1(XueShengBiao xs, BanJiBiao bj)
        {
            XueShengYuBanJiDuiYingBiao xb = new XueShengYuBanJiDuiYingBiao
            {
                StudentID      = xs.ID,
                StudentName    = xs.StudentName,
                StudentClassID = bj.ID,
                StudentClass   = bj.BanJiMing,
                StartTiem      = bj.KaiBanShiJian
            };

            context.XueShengYuBanJiDuiYingBiao.Add(xb);
            return(context.SaveChanges());
        }
Ejemplo n.º 15
0
        public void UpdateActionStu(XueShengBiao stu)
        {
            int n = bll4.UpdateXueSheng(stu);

            if (n > 0)
            {
                Session["Student"] = stu;
                Response.Write("<script>alert('学生信息修改成功');location.href='/YiCipaikedekebiaoxinxi/zhuye'</script>");
            }
            else
            {
                Response.Write("<script>alert('学生信息修改失败,请重试');location.href='/YiCipaikedekebiaoxinxi/zhuye'</script>");
            }
        }
Ejemplo n.º 16
0
        public int HuanBan(string name, int bjID, int Xid, string YuanBanJiID)
        {
            XueShengBiao xs = mbll.GetOne(Xid);
            string       id = xs.StudentClassID.ToString();

            mbj.UpdateNum(xs, 1);
            mbll.XiuGaiShiJian(mbll.GetXueShengYuBanJiDuiYingBiao(Xid, Convert.ToInt32(YuanBanJiID)).ID);
            int n = mbll.HuanBan(Xid, bjID);

            mbll.AddStuClass1(Xid, bjID);
            if (n > 0)
            {
                XueShengBiao xs1 = new XueShengBiao();
                xs1.StudentClassID = bjID;
                mbj.UpdateNum(xs1, 2);
            }
            return(n);
        }
Ejemplo n.º 17
0
        public Student GetOneInfo(object XID)
        {
            XueShengBiao xsb = context.Set <XueShengBiao>().Find(XID);
            BanJiBiao    bjb = context.Set <BanJiBiao>().Find(xsb.StudentClassID);
            Student      st  = new Student
            {
                XID            = xsb.ID,
                StudentName    = xsb.StudentName,
                Address        = xsb.Address,
                Age            = xsb.Age,
                BanJiMing      = bjb.BanJiMing,
                HomePhone      = xsb.HomePhone,
                Phone          = xsb.Phone,
                Sex            = xsb.Sex,
                StudentClassID = xsb.StudentClassID,
                JieDuanID      = Convert.ToInt32(bjb.JieDuanID)
            };

            return(st);
        }
Ejemplo n.º 18
0
        public ActionResult LoginAction(string phone, string pwd, int peo)
        {
            //  0:教员   1:学生
            YuanGongBiao user1 = null;
            XueShengBiao user2 = null;
            int          i     = 0;

            if (peo == 0)
            {
                user1 = bll3.Login(phone, pwd);
                Session.Add("Teacher", user1);
            }
            else if (peo == 1)
            {
                user2 = bll4.Login(phone, pwd);
                Session.Add("Student", user2);
            }
            if (user1 != null || user2 != null)
            {
                i = 1;
            }
            return(Json(new { Count = 1 }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 19
0
        public IHttpActionResult LoginAction(/*[FromBody] Models.YuanGongBiao yuanGongBiao,*/ string Phone, string MiMA)
        {
            YuanGongBiao yuanGongBiao2 = new YuanGongBiao();

            yuanGongBiao2.Phone = Phone;
            yuanGongBiao2.MiMa  = MiMA;
            var Teacher = yuanGong.YuanGongBiao(yuanGongBiao2);

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            string Name = "";

            if (Teacher != null)
            {
                Name = "登录成功";
                context.Session.Add("Teacher", Teacher);
                return(Ok(Name));
            }
            else
            {
                XueShengBiao xueShengBiao = new XueShengBiao
                {
                    MiMa  = yuanGongBiao2.MiMa,
                    Phone = yuanGongBiao2.Phone
                };
                var Student = XueSheng.XueSheng(xueShengBiao);
                if (Student != null)
                {
                    Name = "登录成功";
                    context.Session.Add("Student", Student);
                }
                else
                {
                    Name = "登录失败";
                }
            }
            return(Ok(Name));
        }
Ejemplo n.º 20
0
 public int UpdateXS(XueShengBiao st)
 {
     return(mbll.UpdateXS(st));
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Add学员信息
        /// </summary>
        /// <param name="BanJiMing">班级名</param>
        /// <param name="filePath">文件</param>
        /// <returns></returns>
        public ActionResult StuAddAction(string BanJiMing, string filePath)
        {
            int BanJiID = Convert.ToInt16(BanJiMing);

            if (!string.IsNullOrEmpty(filePath))
            {
                try
                {
                    string path = AppDomain.CurrentDomain.BaseDirectory + @"/upload";
                    //保存文件的真实文件名,和全路径;
                    string savepath = Server.MapPath("~/upload/" + filePath);//上传后的文件名
                    //判断是否存在此路径
                    if (!Directory.Exists(path))
                    {
                        //创建文件夹
                        Directory.CreateDirectory(path);
                    }
                    //创建一个WorkBook对象;
                    HSSFWorkbook hSSFWorkbook;
                    using (FileStream filel = new FileStream(savepath, FileMode.Open, FileAccess.Read))
                    {
                        hSSFWorkbook = new HSSFWorkbook(filel);
                    }
                    //获取工作簿的第一个工作表
                    var sheep = hSSFWorkbook.GetSheetAt(0);
                    //获取所有的行
                    System.Collections.IEnumerator rows = sheep.GetRowEnumerator();
                    //获取标题行
                    var headerRow = sheep.GetRow(0);
                    int cellCount = headerRow.LastCellNum;

                    List <XueShengBiao> stu = new List <XueShengBiao>();

                    for (int i = (sheep.FirstRowNum + 1); i < sheep.LastRowNum; i++)
                    {
                        var          row  = sheep.GetRow(i);
                        XueShengBiao stu1 = new XueShengBiao
                        {
                            StudentName    = (row.GetCell(1).ToString()),
                            StudentClassID = BanJiID,
                            Sex            = Convert.ToInt32(row.GetCell(2).ToString()) == 0 ? false : true,
                            Age            = Convert.ToInt32(row.GetCell(3).ToString()),
                            MiMa           = row.GetCell(4).ToString(),
                            Address        = row.GetCell(5).ToString(),
                            Phone          = row.GetCell(6).ToString(),
                            HomePhone      = row.GetCell(7).ToString(),
                            ZhuangTai      = 1
                        };
                        //把对象加入到集合
                        stu.Add(stu1);
                    }
                    bool error = xsb.StuAdd(stu);
                    if (error)
                    {
                        return(Json(new { errorNo = "0", errorInfo = "导入学员信息成功" }));
                    }
                    else
                    {
                        return(Json(new { errorNo = "1", errorInfo = "导入学员信息失败" }));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { errorNo = "1", errorInfo = ex.Message }));

                    throw ex;
                }
            }
            else
            {
                return(Json(new { errorNo = "1", errorInfo = "无上传文件,操作错误" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 22
0
 public int UpdateXueSheng(XueShengBiao stu)
 {
     return(dal.UpdateXueSheng(stu));
 }