Ejemplo n.º 1
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            var messageCount = 0;

            Response.Write("<!-- ");
            foreach (DataRow row in GetMatchingData().Tables[0].Rows)
            {
                var pid = Convert.ToInt32(row["PID"]);
                var obj = new DAL.Notifications();
                obj.PID_To     = pid;
                obj.PID_From   = 0;
                obj.isQuestion = false;
                obj.Subject    = txtSubject.Text;
                obj.Body       = Body.InnerHtml;
                obj.isUnread   = true;

                obj.AddedDate   = DateTime.Now;
                obj.AddedUser   = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A";  // Get from session
                obj.LastModDate = obj.AddedDate;
                obj.LastModUser = obj.AddedUser;

                if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                {
                    obj.Insert();
                    messageCount++;
                    Response.Write(" :-> ");
                    Response.Flush();
                }
            }
            Response.Write("-->");
            lblSent.Text = string.Format("<br/><br/>A total of {0:#,##0} message were sent.", messageCount);
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Patrons/NotificationsAddEdit.aspx";

            if (e.CommandName.ToLower() == "addrecord")
            {
                Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Response.Redirect(String.Format("{0}?PK={1}", editpage, key));
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = new DAL.Notifications();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        DAL.Notifications.FetchObject(key).Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if (masterPage != null)
                        {
                            masterPage.PageMessage = SRPResources.DeleteOK;
                        }
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        if (masterPage != null)
                        {
                            masterPage.PageError = message;
                        }
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                    }
                }
            }
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Patrons/NotificationsAddEdit.aspx";
            if(e.CommandName.ToLower() == "addrecord") {
                Session["NID"]= string.Empty;
                Response.Redirect(editpage);
            }
            if(e.CommandName.ToLower() == "editrecord") {
                int key = Convert.ToInt32(e.CommandArgument);
                Session["NID"] = key;
                Response.Redirect(editpage);
            }
            if(e.CommandName.ToLower() == "deleterecord") {
                var key = Convert.ToInt32(e.CommandArgument);
                try {
                    var obj = new DAL.Notifications();
                    if(obj.IsValid(BusinessRulesValidationMode.DELETE)) {
                        DAL.Notifications.FetchObject(key).Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if(masterPage != null)
                            masterPage.PageMessage = SRPResources.DeleteOK;
                    } else {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach(BusinessRulesValidationMessage m in obj.ErrorCodes) {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        if(masterPage != null)
                            masterPage.PageError = message;
                    }
                } catch(Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    if(masterPage != null)
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) {
            string returnURL = "~/ControlRoom/Modules/Notifications/NotificationList.aspx";
            if(e.CommandName.ToLower() == "back") {
                Session["Curr_Notification_ID"]= string.Empty;
                Response.Redirect(returnURL);
            }
            if(e.CommandName.ToLower() == "refresh") {
                try {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if(masterPage != null)
                        masterPage.PageMessage = SRPResources.RefreshOK;
                } catch(Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if(e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") {
                try {
                    var reply = new DAL.Notifications();
                    var originalMessage = new DAL.Notifications();
                    int pk = int.Parse(lblPK.Text);
                    originalMessage.Fetch(pk);

                    reply.PID_To = FormatHelper.SafeToInt(Session["CURR_PATRON_ID"].ToString());
                    reply.PID_From = 0;
                    reply.isQuestion = false;
                    reply.Subject = "RE: " + originalMessage.Subject;
                    reply.Body = ((HtmlTextArea)((DetailsView)sender).FindControl("Reply")).InnerHtml;

                    reply.AddedDate = DateTime.Now;
                    reply.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
                    reply.LastModDate = reply.AddedDate;
                    reply.LastModUser = reply.AddedUser;

                    if(reply.IsValid(BusinessRulesValidationMode.INSERT)) {
                        reply.Insert();
                        if(e.CommandName.ToLower() == "saveandback") {

                            //objO.Delete();
                            originalMessage.isUnread = false;
                            originalMessage.Update();

                            Session["CURR_PATRON_ID"]= string.Empty;
                            Session["CURR_PATRON"] = null;
                            Session["CURR_PATRON_MODE"]= string.Empty;
                            Session["Curr_Notification_ID"]= string.Empty;

                            Response.Redirect(returnURL);
                        }

                        //lblPK.Text = obj.NID.ToString();

                        //odsData.DataBind();
                        //dv.DataBind();
                        //dv.ChangeMode(DetailsViewMode.Edit);

                        //var masterPage = (IControlRoomMaster)Master;
                        //masterPage.PageMessage = SRPResources.AddedOK;
                    } else {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach(BusinessRulesValidationMessage m in reply.ErrorCodes) {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                } catch(Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
Ejemplo n.º 5
0
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Patrons/PatronNotifications.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try
                {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageMessage = SRPResources.RefreshOK;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback")
            {
                try
                {
                    var obj = new DAL.Notifications();

                    obj.PID_To     = FormatHelper.SafeToInt(Session["CURR_PATRON_ID"].ToString());
                    obj.PID_From   = 0;
                    obj.isQuestion = false;
                    obj.Subject    = ((TextBox)((DetailsView)sender).FindControl("Subject")).Text;
                    obj.Body       = ((CKEditor.NET.CKEditorControl)((DetailsView)sender).FindControl("Body")).Text;

                    obj.AddedDate   = DateTime.Now;
                    obj.AddedUser   = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A";  // Get from session
                    obj.LastModDate = obj.AddedDate;
                    obj.LastModUser = obj.AddedUser;

                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        obj.Insert();
                        if (e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.NID.ToString();

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            //if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            //{
            //    try
            //    {
            //        var obj = new Notifications();
            //        int pk = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text);
            //        obj.Fetch(pk);

            //        //obj.PID_To = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("PID_To")).SelectedValue);
            //        obj.PID_To = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PID_To")).Text);
            //        //obj.PID_From = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("PID_From")).SelectedValue);
            //        obj.PID_From = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PID_From")).Text);
            //        obj.isQuestion = ((CheckBox)((DetailsView)sender).FindControl("isQuestion")).Checked;
            //        obj.Subject = ((TextBox)((DetailsView)sender).FindControl("Subject")).Text;
            //        obj.Body = ((CKEditor.NET.CKEditorControl)((DetailsView)sender).FindControl("Body")).Text;

            //        obj.LastModDate = DateTime.Now;
            //        obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session

            //        if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
            //        {
            //             obj.Update();
            //            if (e.CommandName.ToLower() == "saveandback")
            //            {
            //                Response.Redirect(returnURL);
            //            }

            //            odsData.DataBind();
            //            dv.DataBind();
            //            dv.ChangeMode(DetailsViewMode.Edit);

            //            var masterPage = (IControlRoomMaster)Master;
            //            masterPage.PageMessage = SRPResources.SaveOK;
            //        }
            //        else
            //        {
            //            var masterPage = (IControlRoomMaster)Master;
            //            string message = String.Format(SRPResources.ApplicationError1, "<ul>");
            //            foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
            //            {
            //                message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
            //            }
            //            message = string.Format("{0}</ul>", message);
            //            masterPage.PageError = message;
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        var masterPage = (IControlRoomMaster)Master;
            //        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
            //    }
            //}
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Notifications/NotificationList.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Session["Curr_Notification_ID"] = string.Empty;
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageMessage = SRPResources.RefreshOK;
                    }
                } catch (Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try {
                    var reply           = new DAL.Notifications();
                    var originalMessage = new DAL.Notifications();
                    int pk = int.Parse(lblPK.Text);
                    originalMessage.Fetch(pk);

                    reply.PID_To     = FormatHelper.SafeToInt(Session["CURR_PATRON_ID"].ToString());
                    reply.PID_From   = 0;
                    reply.isQuestion = false;
                    reply.Subject    = "RE: " + originalMessage.Subject;
                    reply.Body       = ((HtmlTextArea)((DetailsView)sender).FindControl("Reply")).InnerHtml;

                    reply.AddedDate   = DateTime.Now;
                    reply.AddedUser   = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A";  // Get from session
                    reply.LastModDate = reply.AddedDate;
                    reply.LastModUser = reply.AddedUser;

                    if (reply.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        reply.Insert();
                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            //objO.Delete();
                            originalMessage.isUnread = false;
                            originalMessage.Update();

                            Session["CURR_PATRON_ID"]       = string.Empty;
                            Session["CURR_PATRON"]          = null;
                            Session["CURR_PATRON_MODE"]     = string.Empty;
                            Session["Curr_Notification_ID"] = string.Empty;

                            Response.Redirect(returnURL);
                        }

                        //lblPK.Text = obj.NID.ToString();

                        //odsData.DataBind();
                        //dv.DataBind();
                        //dv.ChangeMode(DetailsViewMode.Edit);

                        //var masterPage = (IControlRoomMaster)Master;
                        //masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in reply.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                } catch (Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
        protected void btnSend_Click(object sender, EventArgs e) {
            var messageCount = 0;
            Response.Write("<!-- ");
            foreach(DataRow row in GetMatchingData().Tables[0].Rows) {
                var pid = Convert.ToInt32(row["PID"]);
                var obj = new DAL.Notifications();
                obj.PID_To = pid;
                obj.PID_From = 0;
                obj.isQuestion = false;
                obj.Subject = txtSubject.Text;
                obj.Body = Body.InnerHtml;
                obj.isUnread = true;

                obj.AddedDate = DateTime.Now;
                obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
                obj.LastModDate = obj.AddedDate;
                obj.LastModUser = obj.AddedUser;

                if(obj.IsValid(BusinessRulesValidationMode.INSERT)) {
                    obj.Insert();
                    messageCount++;
                    Response.Write(" :-> ");
                    Response.Flush();
                }
            }
            Response.Write("-->");
            lblSent.Text = string.Format("<br/><br/>A total of {0:#,##0} message were sent.", messageCount);
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Notifications/QuestionView.aspx";
            if (e.CommandName.ToLower() == "addrecord")
            {
                Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);

                var n = DAL.Notifications.FetchObject(key);
                var pid = n.PID_From;


                Session["CURR_PATRON_ID"] = pid;
                Session["CURR_PATRON"] = Patron.FetchObject(pid);
                Session["CURR_PATRON_MODE"] = "EDIT";

                Session["Curr_Notification_ID"] = key;
                Response.Redirect(String.Format("{0}?PK={1}", editpage, key));
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = new DAL.Notifications();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        DAL.Notifications.FetchObject(key).Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if (masterPage != null) masterPage.PageMessage = SRPResources.DeleteOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        if (masterPage != null) masterPage.PageError = message;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
                new Code.ControlRoom.Mail().ClearUnreadCrMailCache(this.Context);
            }
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Patrons/PatronNotifications.aspx";
            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try
                {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                        masterPage.PageMessage = SRPResources.RefreshOK;
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback")
            {
                try
                {
                    var obj = new DAL.Notifications();

                    obj.PID_To = FormatHelper.SafeToInt(Session["CURR_PATRON_ID"].ToString());
                    obj.PID_From = 0;
                    obj.isQuestion = false;
                    obj.Subject = ((TextBox)((DetailsView)sender).FindControl("Subject")).Text;
                    obj.Body = ((HtmlTextArea)((DetailsView)sender).FindControl("Body")).InnerHtml;

                    obj.AddedDate = DateTime.Now;
                    obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
                    obj.LastModDate = obj.AddedDate;
                    obj.LastModUser = obj.AddedUser;

                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        obj.Insert();
                        if (e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.NID.ToString();

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
Ejemplo n.º 10
0
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Patrons/PatronNotifications.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageMessage = SRPResources.RefreshOK;
                    }
                } catch (Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback")
            {
                try {
                    var obj = new DAL.Notifications();

                    obj.PID_To     = FormatHelper.SafeToInt(Session["CURR_PATRON_ID"].ToString());
                    obj.PID_From   = 0;
                    obj.isQuestion = false;
                    obj.Subject    = ((TextBox)((DetailsView)sender).FindControl("Subject")).Text;
                    obj.Body       = ((HtmlTextArea)((DetailsView)sender).FindControl("Body")).InnerHtml;

                    obj.AddedDate   = DateTime.Now;
                    obj.AddedUser   = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A";  // Get from session
                    obj.LastModDate = obj.AddedDate;
                    obj.LastModUser = obj.AddedUser;

                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        obj.Insert();
                        if (e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.NID.ToString();

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                } catch (Exception ex) {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Notifications/QuestionView.aspx";

            if (e.CommandName.ToLower() == "addrecord")
            {
                Response.Redirect(editpage);
            }
            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);

                var n   = DAL.Notifications.FetchObject(key);
                var pid = n.PID_From;


                Session["CURR_PATRON_ID"]   = pid;
                Session["CURR_PATRON"]      = Patron.FetchObject(pid);
                Session["CURR_PATRON_MODE"] = "EDIT";

                Session["Curr_Notification_ID"] = key;
                Response.Redirect(String.Format("{0}?PK={1}", editpage, key));
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = new DAL.Notifications();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        DAL.Notifications.FetchObject(key).Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if (masterPage != null)
                        {
                            masterPage.PageMessage = SRPResources.DeleteOK;
                        }
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        if (masterPage != null)
                        {
                            masterPage.PageError = message;
                        }
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                    }
                }
                new Code.ControlRoom.Mail().ClearUnreadCrMailCache(this.Context);
            }
        }