PageRenderTime 65ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/EMailTemplates.aspx.cs

https://github.com/sirivedula/BEST
C# | 94 lines | 88 code | 6 blank | 0 comment | 12 complexity | 388136fc63cdbcbbdd653a0ede9d6244 MD5 | raw file
  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. using System.Xml.Linq;
  13. using System.Text;
  14. using System.Collections.Generic;
  15. using BaliEnterpriseSystems.BestObjects;
  16. namespace BaliEnterpriseSystems
  17. {
  18. public partial class EMailTemplates : System.Web.UI.Page
  19. {
  20. protected void Page_LoadComplete(object sender, EventArgs e)
  21. {
  22. if (HttpContext.Current.Session["CurrentUser"] == null)
  23. {
  24. Response.Redirect("Logout.aspx");
  25. }
  26. ltrSubMenu.Text = UtilMenu.SetupSubMenu("emailtemplate");
  27. if (!Utils.User.UserRoleByName("Setup - EMail Template").allowView)
  28. {
  29. ltrGrid.Text = "You do not have rights to view.";
  30. return;
  31. }
  32. string ms = Request.QueryString["ms"];
  33. this.ltrMScript.Text = Utils.MenuSelectScript(ms);
  34. if (IsPostBack)
  35. {
  36. BestEMailTemplate bs = new BestEMailTemplate();
  37. string isnew = Request.Form["isnew"];
  38. bool cansave = true;
  39. if (string.IsNullOrEmpty(isnew))
  40. {
  41. List<BestField> bparams = new List<BestField>();
  42. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  43. guid.fieldValue = Request.Form["guidfield"];
  44. bparams.Add(guid);
  45. if (!string.IsNullOrEmpty(guid.fieldValue))
  46. {
  47. bs.LoadRows("guidfield=?", bparams);
  48. }
  49. else
  50. {
  51. string delguid = Request.Form["deleteguid"];
  52. if (!string.IsNullOrEmpty(delguid))
  53. {
  54. bparams[0].fieldValue = delguid;
  55. bs.LoadRows("guidfield=?", bparams);
  56. bs.CurrentRow.IsDelete = true;
  57. bs.CurrentRow.Save();
  58. }
  59. cansave = false;
  60. }
  61. }
  62. if (cansave)
  63. {
  64. if (!string.IsNullOrEmpty(isnew)) { bs.emialTemplateName = Request.Form["g_emialTemplateName"]; }
  65. if (string.IsNullOrEmpty(bs.emialTemplateName))
  66. {
  67. ltrValidateMsg.Text = Utils.WarningMessage("EMial Template Name is Required.");
  68. cansave = false;
  69. }
  70. if (cansave)
  71. {
  72. bs.templateDescription = Request.Form["g_templateDescription"];
  73. if (!bs.CurrentRow.Save())
  74. {
  75. ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
  76. }
  77. }
  78. }
  79. }
  80. BestGrid bsGrid = new BestGrid();
  81. bsGrid.PageRequest = Page.Request;
  82. bsGrid.Title = "EMail Templates Information";
  83. bsGrid.GridTable = new BestEMailTemplate();
  84. bsGrid.securityPage = "Setup - EMail Template";
  85. ltrGrid.Text = bsGrid.ToHTML();
  86. }
  87. }
  88. }