public void GetManualVersions(int ID)
        {
            ManualVersion versions = new ManualVersion();
            versions.GetVersionsByManualID(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.MarkNotificationsReadByManualVersionID(new Guid(Membership.GetUser(Context.User.Identity.Name).ProviderUserKey.ToString()),ID);
            SetContentResult(AllVersions);
        }
        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 BindData_Versions()
 {
     ManualVersion objdata = new ManualVersion();
     objdata.GetVersionsByManualID(CurrentManual.ManualID);
     uiRadGridVersions.DataSource = objdata.DefaultView;
     uiRadGridVersions.DataBind();
 }
        protected void uiRadGridVersions_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditManualVersion")
            {
                ManualVersion objData = new ManualVersion();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxVersionTitle.Text = objData.Title;
                uiTextBoxNotes.Text = objData.Notes;
                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;
                CurrentManualVersion = objData;
                uiPanelEdit.Visible = false;
                uiPanelViewAll.Visible = false;
                uiPanelEditVersions.Visible = true;
                uiPanelVersions.Visible = false;
            }

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

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

                BindData_Versions();
            }
        }
        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();
            }
        }
 protected void uiLinkButtonCancel_Click(object sender, EventArgs e)
 {
     CurrentManual = null;
     CurrentManualVersion = null;
     uiPanelViewAll.Visible = true;
     uiPanelVersions.Visible = false;
     uiPanelEditVersions.Visible = false;
     uiPanelEdit.Visible = false;
     ClearFields();
 }