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 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 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 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 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); } } }