public ActionResult ShowRoommatePage() { //show the home page of roommates if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } //remove gid from the session (added at showExpenses action) Session.Remove("gid"); //get the groups of the user from DB User u = (User)(Session["CurrentUser"]); GroupRoommateDal gdal = new GroupRoommateDal(); List <int> gids = (from g in gdal.GroupsRoommates where g.userName == u.UserName select g.groupID).ToList <int>(); GroupDal groupd = new GroupDal(); List <Group> MyGroups = (from g in groupd.Groups where gids.Contains(g.gid) select g).ToList <Group>(); VMGroups grp = new VMGroups() { Groups = MyGroups }; return(View(grp)); }
void BindGrid() { string strName = txt_GroupName.Text.Trim(); DataTable dt = GroupDal.GetGroups(strName); gvGroup.DataSource = dt; gvGroup.DataBind(); }
public ActionResult AddGroup() { //add new roommate groupaction if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } GroupDal grpDal = new GroupDal(); VMGroups groupsVM = new VMGroups { Group = new Group(), Groups = grpDal.Groups.ToList <Group>() }; return(View(groupsVM)); }
public ActionResult AddGroupSubmit([ModelBinder(typeof(GroupBinder))] Group grp) { //add the new group to DB if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } VMGroups groupsVM = new VMGroups(); GroupDal grpDal = new GroupDal(); ModelState.Clear(); TryValidateModel(grp); if (ModelState.IsValid) { grp.managerUserName = ((User)(Session["CurrentUser"])).UserName; grpDal.Groups.Add(grp); try { grpDal.SaveChanges(); //reset a new group object to view groupsVM.Group = new Group(); GroupRoommate grpRmt = new GroupRoommate() { groupID = grp.gid, userName = grp.managerUserName }; GroupRoommateDal grpRmtDal = new GroupRoommateDal(); grpRmtDal.GroupsRoommates.Add(grpRmt); grpRmtDal.SaveChanges(); ViewBag.addGroupSuccess = "הקבוצה התווספה בהצלחה!"; } catch (DbUpdateException) { ViewBag.addNewGroupError = "התרחשה שגיאה בהוספת הקבוצה"; groupsVM.Group = grp; } } else { groupsVM.Group = grp; } groupsVM.Groups = grpDal.Groups.ToList <Group>(); return(View("AddGroup", groupsVM)); }
protected void gvGroup_RowCommand(object sender, GridViewCommandEventArgs e) { string groupid = e.CommandArgument.ToString(); if (e.CommandName == "dataDelete") { if (GroupDal.DeleteGroupID(groupid)) { MessageBox.popupClientMessage(this.Page, "删除成功!", "call();"); BindGrid(); } else { MessageBox.popupClientMessage(this.Page, "删除错误!", "call();"); return; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnImport.Attributes.Add("onclick", "setDivPos('Lay1');Lay1.style.visibility=''; progress_update();"); TVWMenu.Attributes.Add("onclick", "postBackByObject()"); btnMenuAdd.Attributes.Add("onclick", "javascript:return confirm('确认添加吗?');"); btnMenuModify.Attributes.Add("onclick", "javascript:return confirm('确认修改吗?');"); btnDel.Attributes.Add("onclick", "javascript:return confirm('确认删除该节点及其所有子节点吗?');"); // lbl_MenuID.Text = ""; //lbl_MenuGroups.Text = ""; //授权列表 //权限集合 //dtGroups For Menu DataTable dtGroups = GroupDal.GetGroupsForMenu(); ddl_MenuGroups.Items.Add(new ListItem("sisadmin", "AA")); foreach (DataRow dr in dtGroups.Rows) { ddl_MenuGroups.Items.Add(new ListItem(dr["GroupName"].ToString(), dr["GroupCode"].ToString())); } //目录列表 DataTable dt = KPI_MenuDal.GetDirectories(); ddl_MenuParentID.Items.Add(new ListItem("", "")); foreach (DataRow dr in dt.Rows) { ddl_MenuParentID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString())); } //Treeview BindGrid(); } }
public ActionResult AddUserToGroup() { //add registered users to roommate groups of the current manager if (!Authorize()) { return(RedirectToAction("RedirectByUser", "Home")); } User u = (User)(Session["CurrentUser"]); GroupDal groupd = new GroupDal(); //get only the groups of the manager List <Group> MyGroups = (from g in groupd.Groups where g.managerUserName == u.UserName select g).ToList <Group>(); VMGroups grp = new VMGroups() { Groups = MyGroups }; return(View(grp)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //btnClear.Attributes.Add("onclick", "setDivPos('Lay1');Lay1.style.visibility='';progress_update();"); btnDel.Attributes.Add("onclick", "javascript:return confirm('请确认:从数据库中删除左侧选中的用户吗?');"); //权限集合 //dtGroups For User DataTable dtGroups = GroupDal.GetGroupsForUser(); foreach (DataRow dr in dtGroups.Rows) { ddl_Groups.Items.Add(new ListItem(dr["GroupName"].ToString(), dr["GroupCode"].ToString())); } BindValues(true); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //btnClear.Attributes.Add("onclick", "setDivPos('Lay1');Lay1.style.visibility='';progress_update();"); btnConfirm.Attributes.Add("onclick", "javascript:return confirm('确认无误吗?');"); string opr = Request.QueryString["opr"].ToString(); if (opr == "edit") { btnConfirm.Text = "保 存"; tbxUserCode.Enabled = false; trold.Style.Add("display", "none"); string userid = Request.QueryString["userid"].ToString(); ViewState["userid"] = userid; BindValues(userid); } else if (opr == "add") { btnConfirm.Text = "增 加"; ViewState["userid"] = ""; } //权限集合 //dtGroups For Menu dtGroups = GroupDal.GetGroupsForUser(); ViewState["opr"] = opr; } }
protected void gvGroup_RowUpdating(object sender, GridViewUpdateEventArgs e) { string groupname = ((TextBox)(gvGroup.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim(); string groupdesc = ((TextBox)(gvGroup.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim(); string groupisvalid = ((TextBox)(gvGroup.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim(); string groupnote = ((TextBox)(gvGroup.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim(); string groupid = ((HtmlInputHidden)(gvGroup.Rows[e.RowIndex].Cells[0].FindControl("groupid"))).Value; string msg = ""; if (groupname == "") { msg += "名称不能为空!\r\n"; } if (groupisvalid == "") { msg += "有效性不能为空!\r\n"; } else { try { int.Parse(groupisvalid); } catch { msg += "有效性格式错误!\r\n"; } } if (GroupDal.GroupExist(groupname, groupid)) { MessageBox.popupClientMessage(this.Page, "该组名称已存在!", "call();"); return; } GroupEntity mEntity = new GroupEntity(); mEntity.GroupID = groupid; mEntity.GroupName = groupname; mEntity.GroupDesc = groupdesc; mEntity.GroupIsValid = int.Parse(groupisvalid); mEntity.GroupNote = groupnote; //mEntity.GroupCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); mEntity.GroupModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); if (!GroupDal.Update(mEntity)) { MessageBox.popupClientMessage(this.Page, "修改错误!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "修改成功!", "call();"); gvGroup.EditIndex = -1; BindGrid(); } }
protected void btnAdd_Click(object sender, EventArgs e) { string groupname = tbx_GroupName.Text.Trim(); string groupdesc = tbx_GroupDesc.Text.Trim(); string groupisvalid = ddl_GroupIsValid.Value; string groupnote = tbx_GroupNote.Text.Trim(); // string groupid = Guid.NewGuid().ToString(); string groupcode = GroupDal.GetNextCode(); string msg = ""; if (groupname == "") { msg += "名称不能为空!\r\n"; } if (groupisvalid == "") { msg += "有效性不能为空!\r\n"; } else { try { int.Parse(groupisvalid); } catch { msg += "有效性格式错误!\r\n"; } } if (msg != "") { MessageBox.popupClientMessage(this.Page, msg, "call();"); return; } if (GroupDal.GroupExist(groupname, groupid)) { MessageBox.popupClientMessage(this.Page, "该组名称已存在!", "call();"); return; } GroupEntity mEntity = new GroupEntity(); mEntity.GroupID = groupid; mEntity.GroupCode = groupcode; mEntity.GroupName = groupname; mEntity.GroupDesc = groupdesc; mEntity.GroupIsValid = int.Parse(groupisvalid); mEntity.GroupNote = groupnote; mEntity.GroupCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); mEntity.GroupModifyTime = mEntity.GroupCreateTime; if (!GroupDal.Insert(mEntity)) { MessageBox.popupClientMessage(this.Page, "修改错误!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "修改成功!", "call();"); tbx_GroupName.Text = ""; tbx_GroupDesc.Text = ""; tbx_GroupNote.Text = ""; gvGroup.EditIndex = -1; BindGrid(); } }