PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/ProgramNames.aspx.cs

https://github.com/sirivedula/BEST
C# | 109 lines | 100 code | 9 blank | 0 comment | 13 complexity | 2b3516f506e544e752474d8ad682255e 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 BaliEnterpriseSystems.BestObjects;
  14. using System.Collections.Generic;
  15. using System.Text;
  16. namespace BaliEnterpriseSystems
  17. {
  18. public partial class ProgramNames : 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.ProgramMenu("programinfo");
  27. if (!Utils.User.UserRoleByName("Program - Information").allowView)
  28. {
  29. ltrGrid.Text = "You do not have rights to view.";
  30. return;
  31. }
  32. string ms = Request.QueryString["ms"];
  33. ltrMScript.Text = Utils.MenuSelectScript(ms);
  34. string saveClicked = Request.Form["SaveClicked"] ?? "";
  35. if (IsPostBack && saveClicked.Equals("1"))
  36. {
  37. BestPrograms bs = new BestPrograms();
  38. string isnew = Request.Form["isnew"];
  39. bool cansave = true;
  40. if (string.IsNullOrEmpty(isnew))
  41. {
  42. List<BestField> bparams = new List<BestField>();
  43. BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
  44. guid.fieldValue = Request.Form["guidfield"];
  45. bparams.Add(guid);
  46. if (!string.IsNullOrEmpty(guid.fieldValue))
  47. {
  48. bs.LoadRows("guidfield=?", bparams);
  49. }
  50. else
  51. {
  52. string delguid = Request.Form["deleteguid"];
  53. if (!string.IsNullOrEmpty(delguid))
  54. {
  55. bparams[0].fieldValue = delguid;
  56. bs.LoadRows("guidfield=?", bparams);
  57. bs.CurrentRow.IsDelete = true;
  58. bs.CurrentRow.Save();
  59. }
  60. cansave = false;
  61. }
  62. }
  63. if (cansave)
  64. {
  65. bs.programName = Request.Form["g_programName"];
  66. bs.programType = Request.Form["g_programType"];
  67. if (string.IsNullOrEmpty(bs.programType))
  68. {
  69. ltrValidateMsg.Text = Utils.WarningMessage("Program Type is Required.");
  70. cansave = false;
  71. }
  72. if (cansave)
  73. {
  74. bs.amount = Request.Form["g_amount"];
  75. bs.amountType = Request.Form["g_amountType"];
  76. if (!bs.CurrentRow.Save())
  77. {
  78. ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
  79. }
  80. }
  81. }
  82. }
  83. StringBuilder sb = new StringBuilder();
  84. ProgramTypes bprgTypes = new ProgramTypes();
  85. bprgTypes.LoadRows();
  86. sb.Append("<option value=\"\"></option>");
  87. for(int rowNum = 0; rowNum < bprgTypes.TableRows.Count; rowNum++)
  88. {
  89. sb.Append("<option value=\"" + HttpUtility.HtmlEncode(bprgTypes.TableRows[rowNum].Fields["programType"].fieldValue) + "\">" + HttpUtility.HtmlEncode(bprgTypes.TableRows[rowNum].Fields["programType"].fieldValue) + "</option>");
  90. }
  91. ltrprgTypeOptions.Text = sb.ToString();
  92. BestGrid bsGrid = new BestGrid();
  93. bsGrid.PageRequest = Page.Request;
  94. bsGrid.Title = "Programs Information";
  95. bsGrid.GridTable = new BestPrograms();
  96. bsGrid.securityPage = "Program - Information";
  97. ltrGrid.Text = bsGrid.ToHTML();
  98. }
  99. }
  100. }