Example #1
0
        private void BindData()
        {
            //Bind ddlCategory
            try
            {
                if (CurrentMode.Equals(SPControlMode.New) || CurrentMode.Equals(SPControlMode.Edit))
                {
                    Utilities.BindToDropDown(CurrentWeb, ddlCategory, ListsName.InternalName.CategoryList, FieldsName.CategoryList.InternalName.CategoryID,
                                             FieldsName.CategoryList.InternalName.ParentID, FieldsName.CategoryList.InternalName.Order, FieldsName.CategoryList.InternalName.CategoryLevel);
                }

                if (CurrentMode.Equals(SPControlMode.Edit) || CurrentMode.Equals(SPControlMode.Display))
                {
                    ddlCategory.SelectedValue = Convert.ToString(CurrentItem[FieldsName.DocumentsList.InternalName.CategoryId]);
                }
                if (CurrentMode.Equals(SPControlMode.Display))
                {
                    ddlCategory.Visible   = false;
                    lblCatDisplay.Visible = true;
                    lblCatDisplay.Text    = Convert.ToString(CurrentItem[FieldsName.DocumentsList.InternalName.CategoryName]);
                }
            }
            catch (Exception ex)
            {
                Utilities.LogToULS(ex);
            }
        }
Example #2
0
 /// <summary>
 /// Load default value to control and other initialize.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 ///
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (CurrentMode.Equals(Constants.DisplayForm))
         {
             fuFile.Visible       = false;
             linkFile.Visible     = true;
             linkFile.Text        = Convert.ToString(CurrentItem[FieldsName.AdvList.InternalName.AdvFile]);
             linkFile.NavigateUrl = WebUrl + "/" + Convert.ToString(CurrentItem[FieldsName.AdvList.InternalName.AdvFile]);
             linkFile.Target      = "_blank";
             ltrBr.Text           = "<br /><br />";
         }
         else if (CurrentMode.Equals(Constants.NewForm))
         {
             fuFile.Visible   = true;
             linkFile.Visible = false;
         }
         else if (CurrentMode.Equals(Constants.EditForm))
         {
             fuFile.Visible       = true;
             linkFile.Visible     = true;
             linkFile.Text        = Convert.ToString(CurrentItem[FieldsName.AdvList.InternalName.AdvFile]);
             linkFile.NavigateUrl = WebUrl + "/" + Convert.ToString(CurrentItem[FieldsName.AdvList.InternalName.AdvFile]);
             linkFile.Target      = "_blank";
             ltrBr.Text           = "<br /><br />";
         }
     }
 }
Example #3
0
 private void BindData()
 {
     try
     {
         if (CurrentMode.Equals(SPControlMode.New))
         {
             Utilities.BindToDropDown(CurrentWeb, ddlCategory, ListsName.InternalName.CategoryList, FieldsName.CategoryList.InternalName.CategoryID,
                                      FieldsName.CategoryList.InternalName.ParentID, FieldsName.CategoryList.InternalName.Order, FieldsName.CategoryList.InternalName.CategoryLevel);
         }
         if (CurrentMode.Equals(SPControlMode.Edit))
         {
             Utilities.BindToDropDown(CurrentWeb, ddlCategory, ListsName.InternalName.CategoryList, FieldsName.CategoryList.InternalName.CategoryID,
                                      FieldsName.CategoryList.InternalName.ParentID, FieldsName.CategoryList.InternalName.CategoryLevel,
                                      FieldsName.CategoryList.InternalName.CategoryLevel, Convert.ToString(CurrentItem[FieldsName.CategoryList.InternalName.CategoryID])
                                      , Convert.ToString(CurrentItem[FieldsName.CategoryList.InternalName.ParentID]));
             hidLevel.Value = Convert.ToString(CurrentItem[FieldsName.CategoryList.InternalName.CategoryLevel]);
         }
         if (CurrentMode.Equals(SPControlMode.Display))
         {
             ddlCategory.Visible   = false;
             lblCatDisplay.Visible = true;
             lblCatDisplay.Text    = Convert.ToString(CurrentItem[FieldsName.CategoryList.InternalName.ParentName]);
             hidType.Value         = Convert.ToString(CurrentItem[FieldsName.CategoryList.InternalName.Type]);
         }
     }
     catch (Exception ex)
     {
         Utilities.LogToULS(ex);
     }
 }
Example #4
0
        /// <summary>
        /// Override sharepoint save method.
        /// Create and temporary save a "create account request".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CustomSaveHandler(object sender, EventArgs e)
        {
            SPContext.Current.Web.AllowUnsafeUpdates = true;

            if (CurrentMode == SPControlMode.New)
            {
                CurrentItem[FieldsName.CategoryList.InternalName.CategoryID] = Guid.NewGuid();
            }

            //set category level
            if (!string.IsNullOrEmpty(ddlCategory.SelectedValue))
            {
                CurrentItem[FieldsName.CategoryList.InternalName.CategoryLevel] = Utilities.GetMenuLevel(CurrentWeb, ListsName.InternalName.CategoryList,
                                                                                                         FieldsName.CategoryList.InternalName.CategoryID, ddlCategory.SelectedValue, FieldsName.CategoryList.InternalName.CategoryLevel);
            }
            //set category parent
            CurrentItem[FieldsName.CategoryList.InternalName.ParentID]   = ddlCategory.SelectedValue;
            CurrentItem[FieldsName.CategoryList.InternalName.ParentName] = Utilities.GetValueByField(CurrentWeb, ListsName.InternalName.CategoryList,
                                                                                                     FieldsName.CategoryList.InternalName.CategoryID, ddlCategory.SelectedValue, "Text", FieldsName.CategoryList.InternalName.Title);
            //update category level for all children
            var newLevel = Utilities.ConvertToInt(Utilities.GetValueByField(CurrentWeb, ListsName.InternalName.CategoryList,
                                                                            FieldsName.CategoryList.InternalName.CategoryID, ddlCategory.SelectedValue, "Text", FieldsName.CategoryList.InternalName.CategoryLevel)) + 1;

            if (CurrentMode.Equals(SPControlMode.Edit) && !newLevel.ToString().Equals(hidLevel.Value))
            {
                Utilities.UpdateChildrenLevel(CurrentWeb, ListsName.InternalName.CategoryList, FieldsName.CategoryList.InternalName.CategoryID,
                                              FieldsName.CategoryList.InternalName.ParentID, Convert.ToString(CurrentItem[FieldsName.CategoryList.InternalName.CategoryID]), newLevel + 1,
                                              FieldsName.CategoryList.InternalName.CategoryLevel);
            }
            //Save item to list
            SaveButton.SaveItem(SPContext.Current, false, string.Empty);
        }
 /// <summary>
 /// Override sharepoint save method.
 /// Create and temporary save a "create account request".
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CustomSaveHandler(object sender, EventArgs e)
 {
     CurrentWeb.AllowUnsafeUpdates = true;
     if (CurrentMode.Equals(Constants.NewForm))
     {
         CurrentItem[FieldsName.ExternalNewsLink.InternalName.NewsGroup] = Request.QueryString["CatID"];
     }
     SaveButton.SaveItem(SPContext.Current, false, string.Empty);
 }
Example #6
0
 private void HandleUnitRemoved(UnitRemovedEvent e)
 {
     if (CurrentMode.Equals(GameMode.PlayerOne) || CurrentMode.Equals(GameMode.PlayerOneSetup))
     {
         PlayerOne.Pieces.Remove(e.Unit);
     }
     else if (CurrentMode.Equals(GameMode.PlayerTwo) || CurrentMode.Equals(GameMode.PlayerTwoSetup))
     {
         PlayerTwo.Pieces.Remove(e.Unit);
     }
 }
Example #7
0
 /// <summary>
 /// Override sharepoint save method.
 /// Create and temporary save a "create account request".
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CustomSaveHandler(object sender, EventArgs e)
 {
     if (fuFile.HasFile)
     {
         var    fuFileName = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", Utilities.GetPreByTime(DateTime.Now), fuFile.FileName);
         SPFile file       = Utilities.UploadFileToDocumentLibrary(CurrentWeb, fuFile.PostedFile.InputStream, string.Format(CultureInfo.InvariantCulture,
                                                                                                                            "{0}/{1}/{2}", WebUrl, ListsName.InternalName.AdvFileList, fuFileName));
         CurrentItem[FieldsName.AdvList.InternalName.AdvFile] = file.Url;
     }
     if (CurrentMode.Equals(Constants.NewForm))
     {
         CurrentItem[FieldsName.AdvList.InternalName.AdvID] = Guid.NewGuid();
     }
     CurrentWeb.AllowUnsafeUpdates = true;
     SaveButton.SaveItem(SPContext.Current, false, string.Empty);
 }
Example #8
0
        /// <summary>
        /// Load default value to control and other initialize.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (CurrentMode.Equals(SPControlMode.New))
                {
                    Utilities.BindToDropDown(CurrentWeb, ddlParentName, ListsName.InternalName.MenuList, FieldsName.MenuList.InternalName.MenuID,
                                             FieldsName.MenuList.InternalName.ParentID, FieldsName.MenuList.InternalName.MenuOrder, FieldsName.MenuList.InternalName.MenuLevel);

                    Utilities.BindToDropDown(CurrentWeb, ddlCategory, ListsName.InternalName.CategoryList, FieldsName.CategoryList.InternalName.CategoryID,
                                             FieldsName.CategoryList.InternalName.ParentID, FieldsName.CategoryList.InternalName.Order, FieldsName.CategoryList.InternalName.CategoryLevel);
                }
                if (CurrentMode.Equals(SPControlMode.Edit))
                {
                    Utilities.BindToDropDown(CurrentWeb, ddlParentName, ListsName.InternalName.MenuList, FieldsName.MenuList.InternalName.MenuID,
                                             FieldsName.MenuList.InternalName.ParentID, FieldsName.MenuList.InternalName.MenuOrder,
                                             FieldsName.MenuList.InternalName.MenuLevel, Convert.ToString(CurrentItem[FieldsName.MenuList.InternalName.MenuID])
                                             , Convert.ToString(CurrentItem[FieldsName.MenuList.InternalName.ParentID]));


                    Utilities.BindToDropDown(CurrentWeb, ddlCategory, ListsName.InternalName.CategoryList, FieldsName.CategoryList.InternalName.CategoryID,
                                             FieldsName.CategoryList.InternalName.ParentID, FieldsName.CategoryList.InternalName.Order,
                                             FieldsName.CategoryList.InternalName.CategoryLevel, Convert.ToString(CurrentItem[FieldsName.MenuList.InternalName.CatID]));


                    hidMenuLevel.Value = Convert.ToString(CurrentItem[FieldsName.MenuList.InternalName.MenuLevel]);
                }
                if (CurrentMode.Equals(SPControlMode.Display))
                {
                    ddlParentName.Visible    = false;
                    lblParentNameDsp.Visible = true;
                    lblParentNameDsp.Text    = Convert.ToString(CurrentItem[FieldsName.MenuList.InternalName.ParentName]);
                    ddlCategory.Visible      = false;
                    lblCatDisplay.Visible    = true;
                    lblCatDisplay.Text       = Convert.ToString(CurrentItem[FieldsName.MenuList.InternalName.CatName]);
                    hidType.Value            = Convert.ToString(CurrentItem[FieldsName.MenuList.InternalName.MenuType]);
                }
            }
        }