protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Master.ModuleTitle = "";
                Master.PageTitle = "Manuals";
                LoadCats();
                if (Request.QueryString["cid"] != null)
                {
                    int d = 0;
                    int.TryParse(Request.QueryString["cid"].ToString(), out d);
                    if (d != 0)
                    {
                        RadTreeNode node = uiRadTreeViewCats.FindNodeByValue(d.ToString());
                        node.Selected = true;
                        node.ExpandParentNodes();
                    }
                        //uiRadTreeViewCats.Nodes.FindNodeByValue(d.ToString()).Selected = true;
                }
                else
                    uiRadTreeViewCats.Nodes[0].Selected = true;
                currentManualCat = Convert.ToInt32(uiRadTreeViewCats.SelectedNode.Value);
                ManualCategory cat = new ManualCategory();
                cat.LoadByPrimaryKey(currentManualCat);
                uiLabelCat.Text = cat.Title;
                BindData();

                MarkNotificationsAsRead();
            }
        }
        protected void uiButtonSave_Click(object sender, EventArgs e)
        {
            ManualCategory cat = new ManualCategory ();
            if (CurrentCat != null)
                cat = CurrentCat;
            else
                cat.AddNew();

            cat.Title = uiTextBoxTitle.Text;
            if (currentParentCat != 0)
                cat.ParentCategoryID = currentParentCat;

            cat.Save();
            LoadCats();
            LoadSubCats();

            uiTextBoxTitle.Text = "";
            uiPanelEdit.Visible = false;
            uiPanelViewAll.Visible = true;
        }
 protected void uiRadTreeViewCats_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
 {
     currentManualCat = Convert.ToInt32(e.Node.Value);
     ManualCategory cat = new ManualCategory();
     cat.LoadByPrimaryKey(currentManualCat);
     uiLabelCat.Text = cat.Title;
     BindData();
     LoadCats();
     MarkNotificationsAsRead();
 }
        private void LoadCats()
        {
            ManualCategory cats = new ManualCategory();
            cats.GetAllCatsWithNotifications(new Guid(Membership.GetUser().ProviderUserKey.ToString()));

            uiRadTreeViewCats.DataSource = cats.DefaultView;
            uiRadTreeViewCats.DataFieldID = ManualCategory.ColumnNames.ManualCategoryID;
            uiRadTreeViewCats.DataFieldParentID = ManualCategory.ColumnNames.ParentCategoryID;
            uiRadTreeViewCats.DataTextField = "DisplayName";
            uiRadTreeViewCats.DataValueField = ManualCategory.ColumnNames.ManualCategoryID;
            uiRadTreeViewCats.DataBind();
        }
        protected void uiButtonSaveVersion_Click(object sender, EventArgs e)
        {
            ManualVersion objdata = new ManualVersion();
            if (CurrentManualVersion == null)
            {
                objdata.AddNew();
                objdata.CreatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
                objdata.CreatedDate = DateTime.Now;
            }
            else
                objdata = CurrentManualVersion;
            objdata.Title = uiTextBoxVersionTitle.Text;
            objdata.Notes = uiTextBoxNotes.Text;
            objdata.UpdatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
            objdata.LastUpdatedDate = DateTime.Now;
            objdata.IssueNumber = uiTextBoxIssueNo.Text;
            objdata.RevisionNumber = uiTextBoxRevisionNo.Text;
            if (uiRadDatePickerIssueDate.SelectedDate != null)
                objdata.IssueDate = uiRadDatePickerIssueDate.SelectedDate.Value;
            if (uiRadDatePickerRevisionDate.SelectedDate != null)
                objdata.RevisionDate = uiRadDatePickerRevisionDate.SelectedDate.Value;
            objdata.ManualID = CurrentManual.ManualID;

            if (Session["CurrentUploadedFiles"] != null)
            {
                Hashtable Files;
                Files = (Hashtable)Session["CurrentUploadedFiles"];

                if (Files.Count > 0)
                {
                    foreach (DictionaryEntry item in Files)
                    {
                        objdata.Path = item.Value.ToString();
                    }

                    Session["CurrentUploadedFiles"] = null;
                }

            }

            objdata.Save();
            // add new notifications
            ManualCategory cat = new ManualCategory();
            cat.GetTopMostParent(CurrentManual.ManualCategoryID);

            if (CurrentManual.ManualCategoryID == 12)
            {
                SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, objdata.ManualVersionID, null, null, null);
            }
            else
            {
                if (!cat.IsColumnNull(ManualCategory.ColumnNames.ParentCategoryID))
                {
                    if (cat.ParentCategoryID != 12)
                        SendingNotifications.sendNotif(3, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, objdata.ManualVersionID, null, null, null);
                    else
                        SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, objdata.ManualVersionID, null, null, null);
                }
                else
                    SendingNotifications.sendNotif(3, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, objdata.ManualVersionID, null, null, null);
            }

            BindData_Versions();
            CurrentManualVersion = null;
            uiPanelViewAll.Visible = false;
            uiPanelVersions.Visible = true;
            uiPanelEditVersions.Visible = false;
            uiPanelEdit.Visible = true;
            ClearFields_Versions();
        }
        private void LoadCats()
        {
            ManualCategory cats = new ManualCategory();
            cats.LoadAll();

            uiRadTreeViewCats.DataSource = cats.DefaultView;
            uiRadTreeViewCats.DataFieldID = ManualCategory.ColumnNames.ManualCategoryID;
            uiRadTreeViewCats.DataFieldParentID = ManualCategory.ColumnNames.ParentCategoryID;
            uiRadTreeViewCats.DataTextField = ManualCategory.ColumnNames.Title;
            uiRadTreeViewCats.DataValueField = ManualCategory.ColumnNames.ManualCategoryID;
            uiRadTreeViewCats.DataBind();
        }
        protected void uiButtonSave_Click(object sender, EventArgs e)
        {
            Manual objdata = new Manual();
            if (CurrentManual == null)
            {
                objdata.AddNew();
                objdata.CreatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
                objdata.CreatedDate = DateTime.Now;
            }
            else
                objdata = CurrentManual;
            objdata.Title = uiTextBoxTitle.Text;

            objdata.UpdatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
            objdata.LastUpdatedDate = DateTime.Now;
            //objdata.CreatedBy = uiTextBoxCreatedBy.Text;
            if (currentManualCat != 0)
                objdata.ManualCategoryID = currentManualCat;

            objdata.Save();
            BindData();
            CurrentManual = objdata;
            uiPanelViewAll.Visible = false;
            uiPanelVersions.Visible = true;
            uiPanelEditVersions.Visible = false;
            uiPanelEdit.Visible = true;
            uiLinkButtonEditForms.Visible = true;
            //ClearFields();

            // add new notifications
            ManualCategory cat = new ManualCategory();
            cat.GetTopMostParent(CurrentManual.ManualCategoryID);

            if (CurrentManual.ManualCategoryID == 12)
            {
                SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, null, null, null, null);
            }
            else
            {
                if (!cat.IsColumnNull(ManualCategory.ColumnNames.ParentCategoryID))
                {
                    if (cat.ParentCategoryID != 12)
                        SendingNotifications.sendNotif(3, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, null, null, null, null);
                    else
                        SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, null, null, null, null);
                }
                else
                    SendingNotifications.sendNotif(3, CurrentManual.ManualCategoryID, CurrentManual.ManualID, null, null, null, null, null);
            }
        }
 private void LoadSubCats()
 {
     ManualCategory cats = new ManualCategory();
     cats.GetSubCatByCatID(currentParentCat);
     uiRadGridSubCats.DataSource = cats.DefaultView;
     uiRadGridSubCats.DataBind();
 }
        private void LoadCats()
        {
            ManualCategory cats = new ManualCategory();
            cats.LoadAll();

            uiRadTreeViewCats.DataSource = cats.DefaultView;
            uiRadTreeViewCats.DataFieldID = ManualCategory.ColumnNames.ManualCategoryID;
            uiRadTreeViewCats.DataFieldParentID = ManualCategory.ColumnNames.ParentCategoryID;
            uiRadTreeViewCats.DataTextField = ManualCategory.ColumnNames.Title;
            uiRadTreeViewCats.DataValueField = ManualCategory.ColumnNames.ManualCategoryID;
            uiRadTreeViewCats.DataBind();
            if(currentParentCat != 0)
                uiRadTreeViewCats.Nodes.FindNodeByValue(currentParentCat.ToString()).Selected = true;
        }
        protected void uiRadGridSubCats_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditCat")
            {
                ManualCategory objData = new ManualCategory();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxTitle.Text = objData.Title;
                CurrentCat = objData;
                uiPanelEdit.Visible = true;
                uiPanelViewAll.Visible = false;
            }

            else if (e.CommandName == "DeleteCat")
            {
                ManualCategory objData = new ManualCategory();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                objData.MarkAsDeleted();
                objData.Save();
                LoadSubCats();
                LoadCats();
            }
        }