Пример #1
0
 protected void gvOfficePositionTypes_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         OfficerPositionType opt = e.Row.DataItem as OfficerPositionType;
         if (opt != null)
         {
             CheckBoxList cblTypeFlags = e.Row.FindControl("cblTypeFlagsEdit") as CheckBoxList;
             if (cblTypeFlags != null)
             {
                 foreach (ListItem item in cblTypeFlags.Items)
                 {
                     item.Selected = ((OfficerPositionTypeFlags)int.Parse(item.Value) & opt.TypeFlags) != 0;
                 }
             }
         }
     }
 }
Пример #2
0
        protected void gvOfficePositionTypes_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                using (ScaOpEntities context = new ScaOpEntities())
                {
                    OfficerPositionType opt = new OfficerPositionType();
                    opt.Name = ((TextBox)gvOfficePositionTypes.FooterRow.FindControl("NameAdd")).Text;
                    string description = ((DNNRichTextEditControl)gvOfficePositionTypes.FooterRow.FindControl("textDescriptionAdd")).Value as string;
                    opt.Description = description ?? "";
                    opt.TypeFlags   = GetValueFromTypeFlagCheckBoxList((CheckBoxList)gvOfficePositionTypes.FooterRow.FindControl("cblTypeFlagsAdd"));
                    string sortOrder = ((TextBox)gvOfficePositionTypes.FooterRow.FindControl("SortOrderAdd")).Text;
                    opt.SortOrder = Convert.ToInt32(String.IsNullOrWhiteSpace(sortOrder) ? "0" : sortOrder);

                    context.OfficerPositionTypes.AddObject(opt);
                    context.SaveChanges();
                }
                Response.Redirect(Request.Url.PathAndQuery);
            }
        }
Пример #3
0
 // Helper functions
 /// <summary>
 /// Creates a new user object with the specified values
 /// </summary>
 /// <param name="email">The user's email</param>
 /// <param name="first">The user's first name</param>
 /// <param name="last">The user's last name</param>
 /// <param name="password">The user's password to be hashed</param>
 /// <param name="passwordHint">The user's password hint</param>
 /// <param name="isAdmin">Whether ot not the user is an admin</param>
 /// <param name="isNEC">Whether or not the user is an NEC member</param>
 /// <param name="isFaculty">Whether or not the user is an faculty member</param>
 /// <param name="isTenured">Whether or not the user is tenured</param>
 /// <param name="isUnion">Whether or not the user is in APSCUF</param>
 /// <param name="isBargainingUnit">Whether or not the user is in a bargainingunit committee</param>
 /// <param name="department">The department the faculty member is in</param>
 /// <param name="officerPosition">The officer position of the user</param>
 /// <param name="canVote">Whether or not the user can vote</param>
 /// <param name="currentCommittee">The committee this user serves on</param>
 /// <returns>Returns a user object with the specified officer position</returns>
 public static User CreateUser(string email, string first, string last, string password,
     string passwordHint, bool isAdmin, bool isNEC, bool isFaculty,bool isTenured, bool isUnion,
     bool isBargainingUnit, DepartmentType department,
     OfficerPositionType officerPosition, bool canVote, int currentCommittee)
 {
     User ret = new User();
     ret.Email = email;
     ret.FirstName = first;
     ret.LastName = last;
     ret.Password = Hash(password);
     ret.PasswordHint = passwordHint;
     ret.IsAdmin = isAdmin;
     ret.IsNEC = isNEC;
     ret.IsFaculty = isFaculty;
     ret.IsTenured = isTenured;
     ret.IsUnion = isUnion;
     ret.IsBargainingUnit = isBargainingUnit;
     ret.Department = department;
     ret.OfficerPosition = officerPosition;
     ret.CanVote = canVote;
     ret.CurrentCommittee = currentCommittee;
     return ret;
 }