PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/ProgramsInfo.aspx.cs

https://github.com/sirivedula/BEST
C# | 93 lines | 87 code | 6 blank | 0 comment | 12 complexity | d0f6c6a07a19b38f8bec426bf616200c 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. namespace BaliEnterpriseSystems
  16. {
  17. public partial class ProgramsInfo : System.Web.UI.Page
  18. {
  19. protected void Page_LoadComplete(object sender, EventArgs e)
  20. {
  21. if (HttpContext.Current.Session["CurrentUser"] == null)
  22. {
  23. Response.Redirect("Logout.aspx");
  24. }
  25. ltrSubMenu.Text = UtilMenu.ProgramMenu("programtypes");
  26. if (!Utils.User.UserRoleByName("Program - Types").allowView)
  27. {
  28. ltrGrid.Text = "You do not have rights to view.";
  29. return;
  30. }
  31. string ms = Request.QueryString["ms"];
  32. ltrMScript.Text = Utils.MenuSelectScript(ms);
  33. string saveClicked = Request.Form["SaveClicked"]??"";
  34. if (IsPostBack && saveClicked.Equals("1"))
  35. {
  36. ProgramTypes bs = new ProgramTypes();
  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. bs.programType = Request.Form["g_programType"];
  65. if (string.IsNullOrEmpty(bs.programType))
  66. {
  67. ltrValidateMsg.Text = Utils.WarningMessage("Program Type is Required.");
  68. cansave = false;
  69. }
  70. if (cansave)
  71. {
  72. if (!bs.CurrentRow.Save())
  73. {
  74. ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
  75. }
  76. }
  77. }
  78. }
  79. BestGrid bsGrid = new BestGrid();
  80. bsGrid.PageRequest = Page.Request;
  81. bsGrid.Title = "Program Types Information";
  82. bsGrid.securityPage = "Program - Types";
  83. bsGrid.GridTable = new ProgramTypes();
  84. ltrGrid.Text = bsGrid.ToHTML();
  85. }
  86. }
  87. }