protected void uiButtonSaveVersion_Click(object sender, EventArgs e)
        {
            ScheduleVersion objdata = new ScheduleVersion();
            if (CurrentScheduleVersion == null)
            {
                objdata.AddNew();
                objdata.CreatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
                objdata.CreatedDate = DateTime.Now;
            }
            else
                objdata = CurrentScheduleVersion;
            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.ScheduleID = CurrentSchedule.ScheduleID;

            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(8, null, null, null, null, null, CurrentSchedule.ScheduleID ,objdata.ScheduleVersionID);

            /*ManualCategory cat = new ManualCategory();
            cat.GetTopMostParent(CurrentSchedule.ManualCategoryID);

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

            BindData_Versions();
            CurrentScheduleVersion = null;
            uiPanelViewAll.Visible = false;
            uiPanelVersions.Visible = true;
            uiPanelEditVersions.Visible = false;
            uiPanelEdit.Visible = true;
            ClearFields_Versions();
        }
 private void BindData_Versions()
 {
     ScheduleVersion objdata = new ScheduleVersion();
     objdata.GetVersionsByScheduleID(CurrentSchedule.ScheduleID);
     uiRadGridVersions.DataSource = objdata.DefaultView;
     uiRadGridVersions.DataBind();
 }
        protected void uiRadGridVersions_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditVersion")
            {
                ScheduleVersion objData = new ScheduleVersion();
                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(ScheduleVersion.ColumnNames.IssueDate))
                    uiRadDatePickerIssueDate.SelectedDate = objData.IssueDate;
                if (!objData.IsColumnNull(ScheduleVersion.ColumnNames.RevisionDate))
                    uiRadDatePickerRevisionDate.SelectedDate = objData.RevisionDate;
                CurrentScheduleVersion = objData;
                uiPanelEdit.Visible = false;
                uiPanelViewAll.Visible = false;
                uiPanelEditVersions.Visible = true;
                uiPanelVersions.Visible = false;
            }

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

                ScheduleVersion versions = new ScheduleVersion();
                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 == "EditSchedule")
            {
                Schedule objData = new Schedule();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxTitle.Text = objData.Name;
                if (!objData.IsColumnNull(Schedule.ColumnNames.StartDate))
                    uiRadDatePickerStartDate.SelectedDate = objData.StartDate;
                if (!objData.IsColumnNull(Schedule.ColumnNames.EndDate))
                    uiRadDatePickerEndDate.SelectedDate = objData.EndDate;
                CurrentSchedule = objData;
                uiPanelEdit.Visible = true;
                uiPanelViewAll.Visible = false;
                uiPanelEditVersions.Visible = false;
                uiPanelVersions.Visible = true;

                BindData_Versions();
            }

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

                ScheduleVersion versions = new ScheduleVersion();
                versions.GetVersionsByScheduleID(objData.ScheduleID);
                versions.DeleteAll();
                versions.Save();

                objData.MarkAsDeleted();
                objData.Save();
                BindData();
            }
        }
 protected void uiLinkButtonCancel_Click(object sender, EventArgs e)
 {
     CurrentSchedule = null;
     CurrentScheduleVersion = null;
     uiPanelViewAll.Visible = true;
     uiPanelVersions.Visible = false;
     uiPanelEditVersions.Visible = false;
     uiPanelEdit.Visible = false;
     ClearFields();
 }
        public void GetScheduleVersions(int ID)
        {
            ScheduleVersion versions = new ScheduleVersion();
            versions.GetVersionsByScheduleID(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.MarkNotificationsReadByScheduleVersionID(new Guid(Membership.GetUser(Context.User.Identity.Name).ProviderUserKey.ToString()), ID);
            SetContentResult(AllVersions);
        }