You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
5.3 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using Swift.web.Library;
  8. using Swift.DAL.SwiftDAL;
  9. using Swift.DAL.RiskBasedAssessment;
  10. using Swift.web.Component.Grid;
  11. using System.Data;
  12. namespace Swift.web.RiskBasedAssessment
  13. {
  14. public partial class PeriodicRiskAssessment : Page
  15. {
  16. private string ViewFunctionId = "2022000";
  17. private string AddEditFunctionId = "2022010";
  18. private readonly RemittanceLibrary _sdd = new RemittanceLibrary();
  19. RiskBasedAssessmentDao _rbaDao = new RiskBasedAssessmentDao();
  20. public string criteriaID;
  21. protected void Page_Load(object sender, EventArgs e)
  22. {
  23. Authenticate();
  24. criteriaID = Request.QueryString["criteriaId"];
  25. if (!IsPostBack)
  26. {
  27. PopulateDDL();
  28. if (criteriaID != "" && criteriaID != null)
  29. {
  30. populateCriteria(criteriaID);
  31. }
  32. }
  33. }
  34. private void Authenticate()
  35. {
  36. _sdd.CheckAuthentication(ViewFunctionId);
  37. }
  38. private void PopulateDDL()
  39. {
  40. _sdd.SetDDL(ref Criteria, "EXEC proc_dropDownLists2 @FLAG='pcriteria'", "value", "text", "", "");
  41. _sdd.SetDDL(ref Condition, "EXEC proc_dropDownLists2 @FLAG='condition'", "value", "text", "", "");
  42. }
  43. protected void btnSave_Click(object sender, EventArgs e)
  44. {
  45. if (Validation())
  46. {
  47. Save();
  48. }
  49. else
  50. {
  51. GetStatic.AlertMessage(Page);
  52. }
  53. }
  54. private void Save()
  55. {
  56. string criteria = Criteria.SelectedValue.ToString();
  57. string condition = Condition.SelectedValue.ToString();
  58. string minValue = MinValue.Text.ToString();
  59. string maxValue = MaxValue.Text.ToString();
  60. string result = Result.Text.ToString();
  61. string weight = Weight.Text.ToString();
  62. string user = GetStatic.GetUser();
  63. string flag;
  64. if (criteriaID!="" && criteriaID != null)
  65. {
  66. flag = "u";
  67. }
  68. else
  69. {
  70. flag = "i";
  71. }
  72. DbResult dbResult = _rbaDao.SaveRiskAssessment(flag, criteriaID, criteria, condition, minValue, maxValue, result, weight, user);
  73. ManageMessage(dbResult);
  74. }
  75. private bool Validation()
  76. {
  77. if (Criteria.SelectedValue.ToString() == "")
  78. {
  79. GetStatic.AlertMessage(this, "Please select valid Criteria! ");
  80. Criteria.Focus();
  81. return false;
  82. }
  83. if (Condition.SelectedValue.ToString() == "")
  84. {
  85. GetStatic.AlertMessage(this, "Please select valid Condition! ");
  86. Condition.Focus();
  87. return false;
  88. }
  89. if (string.IsNullOrEmpty(MinValue.Text) == true)
  90. {
  91. GetStatic.AlertMessage(this, "Please enter valid Min Value! ");
  92. MinValue.Focus();
  93. return false;
  94. }
  95. if (string.IsNullOrEmpty(MaxValue.Text)==true)
  96. {
  97. GetStatic.AlertMessage(this, "Please enter valid Max Value! ");
  98. MaxValue.Focus();
  99. return false;
  100. }
  101. if (GetStatic.ParseDouble(MinValue.Text)> GetStatic.ParseDouble(MaxValue.Text))
  102. {
  103. GetStatic.AlertMessage(this, "Max Value must be Greater Than Min Value! ");
  104. MaxValue.Focus();
  105. return false;
  106. }
  107. if (GetStatic.ParseDouble(Result.Text) <= 0)
  108. {
  109. GetStatic.AlertMessage(this, "Please enter valid Result! ");
  110. Result.Text = "";
  111. Result.Focus();
  112. return false;
  113. }
  114. if (GetStatic.ParseDouble(Weight.Text) <= 0)
  115. {
  116. GetStatic.AlertMessage(this, "Please enter valid Weight! ");
  117. Weight.Text = "";
  118. Weight.Focus();
  119. return false;
  120. }
  121. return true;
  122. }
  123. private void populateCriteria(string criteriaID)
  124. {
  125. DataTable dt = _rbaDao.GetRiskAssessment("s", criteriaID);
  126. Criteria.SelectedValue=dt.Rows[0]["Criteria"].ToString();
  127. Condition.SelectedValue=dt.Rows[0]["Condition"].ToString();
  128. MinValue.Text=dt.Rows[0]["CriteriaDetail"].ToString();
  129. MaxValue.Text = dt.Rows[0]["CriteriaDetail2"].ToString();
  130. Result.Text = dt.Rows[0]["Result"].ToString();
  131. Weight.Text = dt.Rows[0]["Weight"].ToString();
  132. }
  133. private void ManageMessage(DbResult dbResult)
  134. {
  135. GetStatic.SetMessage(dbResult);
  136. if (dbResult.ErrorCode == "0")
  137. {
  138. Response.Redirect("List.aspx?Id=" + Criteria.SelectedValue.ToString() + "&condition=" + Condition.SelectedValue.ToString());
  139. }
  140. else
  141. {
  142. GetStatic.PrintMessage(Page);
  143. }
  144. }
  145. }
  146. }