예제 #1
0
        public string UpdateTeam_Organizations(Team_Organizations To)
        {
            var Re = context.Team_Organization.FirstOrDefault(d => d.TO_Id == To.TO_Id);

            if (Re != null)
            {
                Re.TO_Name              = To.TO_Name;
                Re.TO_Unversity         = To.TO_Unversity;
                Re.TO_Create_Person     = To.TO_Create_Person;
                Re.TO_CreateTime        = To.TO_CreateTime;
                Re.TO_PersonStudyNumber = To.TO_PersonStudyNumber;
                Re.TO_Signature         = To.TO_Signature;
                Re.TO_State             = To.TO_State;
                Re.TO_Image             = To.TO_Image;
                Re.To_Star              = To.To_Star;
                try
                {
                    context.SaveChanges();
                    return("Success");
                }
                catch (Exception)
                {
                    return("error");
                }
            }
            else
            {
                return("该用户不存在");
            }
        }
예제 #2
0
        public int AddTeam_Organizations(Team_Organizations to)
        {
            var To = new Team_Organizations()
            {
                TO_Name              = to.TO_Name,
                TO_Unversity         = to.TO_Unversity,
                TO_Create_Person     = to.TO_Create_Person,
                TO_CreateTime        = to.TO_CreateTime,
                TO_Signature         = to.TO_Signature,
                TO_State             = to.TO_State,
                TO_PersonStudyNumber = to.TO_PersonStudyNumber,
                TO_Image             = to.TO_Image,
                To_Star              = to.To_Star
            };

            context.Set <Team_Organizations>().Add(To);
            try {
                context.SaveChanges();
                return(To.TO_Id);
            }
            catch (Exception)
            {
                return(0);
            }
        }
예제 #3
0
        protected void submit_Click(object sender, EventArgs e)
        {
            if (Session["UserCount_Someone"] == null || Session["UserCount_Someone"].ToString() == "")
            {
                Response.Write("<script>alert('请先登录')</script>");
                Response.Redirect("login.aspx");
            }
            else if (teamname.Text == "" || cologename.Text == "" || cologenumber.Text == "")
            {
                Response.Write("<script>alert('请填写正确的信息')</script>");
            }
            else if (cto.GetTO_number(Session["UserCount_Someone"].ToString()) > 3)
            {
                Response.Write("<script>alert('你已经超过建立社团的上限')</script>");
            }
            else
            {
                var TO = new Team_Organizations()
                {
                    TO_Name              = teamname.Text,
                    TO_Unversity         = cologename.Text,
                    TO_PersonStudyNumber = cologenumber.Text,
                    TO_Signature         = teaminstraction.Text,
                    TO_CreateTime        = DateTime.Now,
                    TO_Create_Person     = Session["UserCount_Someone"].ToString(),
                    TO_State             = "available",
                    To_Star              = 0
                };

                int message = apm.AddTeam_Organizations(TO);
                if (message != 0)
                {
                    try
                    {
                        string pho = Session["UserCount_Someone"].ToString();
                        var    xx  = context.User_Counts.FirstOrDefault(p => p.Users_Phone == pho);
                        if (xx != null)
                        {
                            xx.Users_CreateTO = xx.Users_CreateTO + message.ToString() + ",";
                            context.SaveChanges();
                            Response.Write("<script>alert('success')</script>");
                        }
                    }
                    catch (Exception)
                    {
                        Response.Write("<script>alert('将社团ID添加至用户表出错')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('" + message + "')</script>");
                }
            }
        }
예제 #4
0
        public string RemoveTeam_Organizations(Team_Organizations to)
        {
            var To = context.Team_Organization.FirstOrDefault(p => p.TO_Id == to.TO_Id);

            if (To != null)
            {
                try
                {
                    context.Team_Organization.Remove(To);
                    context.SaveChanges();
                    return("该社团已经被删除");
                } catch (Exception)
                {
                    return("删除失败");
                }
            }
            else
            {
                return("社团不存在");
            }
        }