PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/BestServicesInfo.aspx.cs

https://github.com/sirivedula/BEST
C# | 96 lines | 89 code | 7 blank | 0 comment | 12 complexity | 5f87c9b0b6525bbb6f16a032fb0c9f2e 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 BestServicesPageInfo : 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("services");
  26. if (!Utils.User.UserRoleByName("Setup - Services").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. string saveClicked = Request.Form["SaveClicked"] ?? "";
  34. if (IsPostBack && saveClicked.Equals("1"))
  35. {
  36. BestServices bs = new BestServices();
  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.Service = Request.Form["g_Service"];
  65. bs.CenterId = Request.Form["g_CenterId"];
  66. if (string.IsNullOrEmpty(bs.Service))
  67. {
  68. ltrValidateMsg.Text = Utils.WarningMessage("Service is Required.");
  69. cansave = false;
  70. }
  71. if (cansave)
  72. {
  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 = "Services Information";
  83. bsGrid.GridTable = new BestServices();
  84. bsGrid.securityPage = "Setup - Services";
  85. bsGrid.orderby = "service";
  86. ltrGrid.Text = bsGrid.ToHTML();
  87. }
  88. }
  89. }