PageRenderTime 47ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/BestCenterInfo.aspx.cs

https://github.com/sirivedula/BEST
C# | 105 lines | 96 code | 9 blank | 0 comment | 13 complexity | c951a6f5f603333e87c2b32da19bdec1 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 BestCenterPageInfo : 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.SetupSubMenu("centers");
  26. if (!Utils.User.UserRoleByName("Setup - Center Information").allowView)
  27. {
  28. ltrGrid.Text = "You do not have rights to view.";
  29. return;
  30. }
  31. string ms = Request.QueryString["ms"];
  32. this.ltrMScript.Text = Utils.MenuSelectScript(ms);
  33. ltrState.Text = Utils.StateOptions();
  34. string saveClicked = Request.Form["SaveClicked"] ?? "";
  35. if (IsPostBack && saveClicked.Equals("1"))
  36. {
  37. BestCenters bs = new BestCenters();
  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. if (!string.IsNullOrEmpty(isnew)) { bs.CenterId = Request.Form["g_CenterId"]; }
  66. if (string.IsNullOrEmpty(bs.CenterId))
  67. {
  68. ltrValidateMsg.Text = Utils.WarningMessage("Center Id is Required.");
  69. cansave = false;
  70. }
  71. if (cansave)
  72. {
  73. bs.address1 = Request.Form["g_address1"];
  74. bs.address2 = Request.Form["g_address2"];
  75. bs.city = Request.Form["g_city"];
  76. bs.contactEMail = Request.Form["g_contactEMail"];
  77. bs.contactName = Request.Form["g_contactName"];
  78. bs.contactPhone = Request.Form["g_contactPhone"];
  79. bs.state = Request.Form["g_state"];
  80. bs.zip = Request.Form["g_zip"];
  81. if (!bs.CurrentRow.Save())
  82. {
  83. ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
  84. }
  85. }
  86. }
  87. }
  88. BestGrid bsGrid = new BestGrid();
  89. bsGrid.PageRequest = Page.Request;
  90. bsGrid.Title = "Center Information";
  91. bsGrid.securityPage = "Setup - Center Information";
  92. bsGrid.GridTable = new BestCenters();
  93. ltrGrid.Text = bsGrid.ToHTML();
  94. }
  95. }
  96. }