public void GetFormVersions(int ID)
        {
            FromVersion versions = new FromVersion();
            versions.GetVersionsByFormID(ID);

            List<Version> AllVersions = versions.DefaultView.Table.AsEnumerable().Select(row =>
            {
                return new Version
                {
                    Title = row["Title"].ToString(),
                    IssueNumber = row["IssueNumber"].ToString(),
                    IssueDate = DateTime.Parse(row["IssueDate"].ToString()),
                    RevisionNumber = row["RevisionNumber"].ToString(),
                    RevisionDate = DateTime.Parse(row["RevisionDate"].ToString()),
                    UpdatedByName = row["UpdatedByName"].ToString(),
                    LastUpdatedDate = DateTime.Parse(row["LastUpdatedDate"].ToString()),
                    Path = row["Path"].ToString()
                };

            }).ToList();
            UsersNofications usNot = new UsersNofications();
            usNot.MarkNotificationReadByFormVersionID(new Guid(Membership.GetUser(Context.User.Identity.Name).ProviderUserKey.ToString()), ID);
            SetContentResult(AllVersions);
        }
        protected void uiRadGridmanuals_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditManual")
            {
                Manual objData = new Manual();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxTitle.Text = objData.Title;

                CurrentManual = objData;
                uiPanelEdit.Visible = true;
                uiPanelViewAll.Visible = false;
                uiPanelEditVersions.Visible = false;
                uiPanelVersions.Visible = true;
                uiLinkButtonEditForms.Visible = true;
                BindData_Versions();
            }

            else if (e.CommandName == "DeleteManual")
            {
                Manual objData = new Manual();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                ManualVersion versions = new ManualVersion();
                versions.GetVersionsByManualID(objData.ManualID);
                versions.DeleteAll();
                versions.Save();

                ManualForm forms = new ManualForm();
                forms.GetFormsByManualID(objData.ManualID);
                for (int i = 0; i < forms.RowCount; i++)
                {
                    FromVersion formversions = new FromVersion();
                    formversions.GetVersionsByFormID(forms.ManualFormID);
                    formversions.MarkAsDeleted();
                    formversions.Save();
                }

                forms.DeleteAll();
                forms.Save();

                objData.MarkAsDeleted();
                objData.Save();
                BindData();
            }
        }
 private void BindData_Versions()
 {
     FromVersion objdata = new FromVersion();
     objdata.GetVersionsByFormID(CurrentForm.ManualFormID);
     uiRadGridVersions.DataSource = objdata.DefaultView;
     uiRadGridVersions.DataBind();
 }
        protected void uiButtonSaveVersion_Click(object sender, EventArgs e)
        {
            FromVersion objdata = new FromVersion();
            if (CurrentFormVersion == null)
            {
                objdata.AddNew();
                objdata.CreatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
                objdata.CreatedDate = DateTime.Now;
            }
            else
                objdata = CurrentFormVersion;
            objdata.Title = uiTextBoxVersionTitle.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.ManualFromID = CurrentForm.ManualFormID;
            objdata.Notes = uiTextBoxNotes.Text;
            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
            //SendingNotifications.sendNotif(4, CurrentManual.ManualCategoryID, null, CurrentForm.ManualFormID,null,objdata.FromVersionID);

            ManualCategory cat = new ManualCategory();
            cat.GetTopMostParent(CurrentManual.ManualCategoryID);

            if (CurrentManual.ManualCategoryID == 12)
            {
                SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, objdata.FromVersionID, null, null);
            }
            else
            {
                if (!cat.IsColumnNull(ManualCategory.ColumnNames.ParentCategoryID))
                {
                    if (cat.ParentCategoryID != 12)
                        SendingNotifications.sendNotif(4, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, objdata.FromVersionID, null, null);
                    else
                        SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, objdata.FromVersionID, null, null);
                }
                else
                    SendingNotifications.sendNotif(4, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, objdata.FromVersionID, null, null);
            }
            BindData_Versions();
            CurrentFormVersion = null;
            uiPanelViewAll.Visible = false;
            uiPanelVersions.Visible = true;
            uiPanelEditVersions.Visible = false;
            uiPanelEdit.Visible = true;
            ClearFields_Versions();
        }
        protected void uiRadGridVersions_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditVersion")
            {
                FromVersion objData = new FromVersion();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxVersionTitle.Text = objData.Title;
                uiTextBoxNotes.Text= objData.Notes;
                //uiTextBoxCreatedBy.Text = objData.CreatedBy;
                uiTextBoxIssueNo.Text = objData.IssueNumber;
                uiTextBoxRevisionNo.Text = objData.RevisionNumber;
                if (!objData.IsColumnNull(ManualVersion.ColumnNames.IssueDate))
                    uiRadDatePickerIssueDate.SelectedDate = objData.IssueDate;
                if (!objData.IsColumnNull(ManualVersion.ColumnNames.RevisionDate))
                    uiRadDatePickerRevisionDate.SelectedDate = objData.RevisionDate;
                CurrentFormVersion = objData;
                uiPanelEdit.Visible = false;
                uiPanelViewAll.Visible = false;
                uiPanelEditVersions.Visible = true;
                uiPanelVersions.Visible = false;
            }

            else if (e.CommandName == "DeleteVersion")
            {

                FromVersion versions = new FromVersion();
                versions.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                versions.MarkAsDeleted();
                versions.Save();

                BindData_Versions();
            }
        }