예제 #1
0
        public bool AddTeaToTG(string teaname, string tgname)
        {
            TeaGroupDal          tgdal = new TeaGroupDal();
            Teacher              t     = new Teacher();
            TeaGroup             tg    = new TeaGroup();
            IQueryable <Teacher> iqtea = teaDal.GetEntities(u => u.Tea_Name == teaname);

            foreach (var item in iqtea)
            {
                t = item;
            }
            IQueryable <TeaGroup> iqtg = tgdal.GetEntities(u => u.TG_Name == tgname);

            foreach (var item in iqtg)
            {
                tg = item;
            }
            DBSession db = new DBSession();

            t.TeaGroup = tg;
            if (teaDal.UpdateEntity(t) != null)
            {
                db.SaveChanges();
                return(true);
            }
            ;
            return(false);
        }
예제 #2
0
        public ActionResult GetTeaGroupByDep()
        {
            string                dep    = Request["dep"];
            TeaGroupDal           tgdal  = new TeaGroupDal();
            TeacherDal            teadal = new TeacherDal();
            IQueryable <TeaGroup> iq     = tgdal.GetEntities(u => u.Department.Dep_Name == dep);
            IList <string>        ls     = new List <string>();

            foreach (var item in iq)
            {
                string         lstr = "";
                IList <string> l    = new List <string>();
                l.Add(item.TG_Id + "-" + item.TG_Name + "-");
                TeaGroup             t     = item;
                IQueryable <Teacher> teaiq = teadal.GetEntities(u => u.TeaGroup == t);
                foreach (var item1  in teaiq)
                {
                    l.Add(item1.Tea_Name + "  ");
                }
                for (int i = 0; i < l.Count(); i++)
                {
                    lstr = lstr + l[i];
                }
                ls.Add(lstr);
            }
            string str = js.Serialize(ls);

            // Session["tgmanage"] = ls;
            Response.Write(str);
            string s = string.Empty;

            Response.End();
            return(View());
        }
예제 #3
0
        public ActionResult AddTeaGroup()
        {
            TeaGroupDal tgdal   = new TeaGroupDal();
            string      depname = Request["dep"];
            string      tgname  = Request["tgname"];

            if (string.IsNullOrEmpty(tgname))
            {
                Response.Write("小组名不能为空");
                Response.End();
                return(null);
            }
            IQueryable <TeaGroup> iq = tgdal.GetEntities(u => u.TG_Name == tgname);

            if (iq.Count() > 0)
            {
                Response.Write("小组已存在不能重复添加");
                Response.End();
                return(null);
            }
            DepartmentService depser = new DepartmentService();
            Department        dep    = depser.GetDepartmentByName(depname);
            TeaGroup          tg     = new TeaGroup();

            tg.TG_Name    = tgname;
            tg.Department = dep;
            TeaGroupService tgser = new TeaGroupService();

            tgser.Add(tg);
            Response.Write("添加成功");
            Response.End();
            return(null);
        }
예제 #4
0
        public ActionResult AddOneTea()
        {
            DepartmentService     depser = new DepartmentService();
            TeaGroupDal           tegd   = new TeaGroupDal();
            TeaGroup              t      = new TeaGroup();
            IQueryable <TeaGroup> iq     = tegd.GetEntities(u => u.TG_Id == 1);

            foreach (var item in iq)
            {
                t = item;
            }
            //DepartmentDal depdal = new DepartmentDal();
            TeacherService teaser  = new TeacherService();
            string         teanum  = Request["teanum"];
            string         teaname = Request["teaname"];
            string         teasex  = Request["teasex"];
            string         teadep  = Request["teadep"];
            Department     dep     = depser.GetDepartmentByName(teadep);
            Teacher        tea     = new Teacher();

            tea.Tea_Num = teanum;
            if (teanum == "" || teaname == "")
            {
                Response.Write("工号姓名不能为空!");
                Response.End();
                return(null);
            }

            Teacher tea2 = teaser.GetTeacherByNum(teanum);

            if (tea2 != null)
            {
                Response.Write("此老师已存在,不能重复添加");
                Response.End();
                return(null);
            }
            tea.Tea_Name   = teaname;
            tea.Tea_Pwd    = "123";
            tea.Tea_Sex    = teasex;
            tea.Department = dep;
            // tea.Tea_Email = "";
            tea.Tea_Photo = "";
            tea.Tea_Tel   = "";
            // tea.TeaGroup = t;
            teaser.AddOneTea(tea);

            Response.Write("添加成功");
            Response.End();
            return(null);
        }