protected void buttonOk_Click(object sender, EventArgs e) { Guid? id = null; foreach (var r in view.Items.Select(o => o.FindControl("btn")).Where(r => ((RadButton) r).Checked)) { id = Guid.Parse(((RadButton) r).Value); break; } if (id.HasValue) { var groupId = Guid.Parse(Request.QueryString[0]); HomoryContext.Value.GroupUser.Where(o => o.GroupId == groupId && o.Type == GroupUserType.创建者 && o.State < State.审核).Update(o => new GroupUser { State = State.删除 }); var gu = new GroupUser { GroupId = groupId, UserId = id.Value, Type = GroupUserType.创建者, State = State.启用, Ordinal = 0, Time = DateTime.Now }; HomoryContext.Value.GroupUser.AddOrUpdate(gu); HomoryContext.Value.SaveChanges(); panelInner.ResponseScripts.Add("RadClose();"); } }
protected void btn_Click(object sender, EventArgs e) { var state = ((RadButton) sender).Checked ? State.启用 : State.删除; var groupId = Guid.Parse(Request.QueryString[0]); var id = Guid.Parse(((RadButton) sender).Value); var gu = new GroupUser { GroupId = groupId, UserId = id, Type = GroupUserType.组成员, State = state, Ordinal = 1, Time = DateTime.Now }; HomoryContext.Value.GroupUser.AddOrUpdate(gu); HomoryContext.Value.SaveChanges(); }
protected void btnCreate_ServerClick(object sender, EventArgs e) { var dir = new DirectoryInfo(Server.MapPath("~/GroupIcon")); var files = dir.GetFiles("*.png").Select(o => "~/GroupIcon/" + o.Name).OrderBy(o => o).ToList(); var g = new Group(); g.Icon = icons.SelectedItems.Count == 0 ? "~/Common/默认/群组.png" : files[icons.SelectedIndexes[0]]; g.Id = HomoryContext.Value.GetId(); g.Introduction = intro.Text; g.Name = name.Text; g.OpenType = OpenType.互联网; g.Ordinal = 1; g.State = State.启用; g.Type = GroupType.教研团队; int s = new Random().Next(10000000, 99999999); string sx=s.ToString(); while(HomoryContext.Value.Group.Count(o=>o.Serial==sx)>0) { s = new Random().Next(10000000, 99999999); sx = s.ToString(); } if (publish_course.SelectedIndex > 0) g.CourseId = Guid.Parse(publish_course.SelectedItem.Value); if (publish_grade.SelectedIndex > 0) g.GradeId = Guid.Parse(publish_grade.SelectedItem.Value); g.Serial = sx; var gu = new GroupUser(); gu.GroupId = g.Id; gu.Ordinal = 0; gu.State = State.启用; gu.Time = DateTime.Now; gu.Type = GroupUserType.创建者; gu.UserId = CurrentUser.Id; HomoryContext.Value.Group.Add(g); HomoryContext.Value.GroupUser.Add(gu); HomoryContext.Value.SaveChanges(); panel.ResponseScripts.Add("RadCloseRebind();"); }