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.

308 lines
14 KiB

10 months ago
  1. using Newtonsoft.Json;
  2. using Swift.API.Common;
  3. using Swift.API.Common.Enum;
  4. using Swift.API.TPAPIs;
  5. using Swift.DAL.OnlineAgent;
  6. using Swift.DAL.SwiftDAL;
  7. using Swift.web.Component.Grid;
  8. using Swift.web.Component.Grid.gridHelper;
  9. using Swift.web.Library;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Linq;
  14. using System.Web;
  15. using System.Web.UI;
  16. using System.Web.UI.WebControls;
  17. namespace Swift.web.Remit.Administration.CustomerRegistration
  18. {
  19. public partial class UpdateKYC : System.Web.UI.Page
  20. {
  21. private const string GridName = "grid_list";
  22. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  23. private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
  24. private readonly SwiftLibrary _swiftLib = new SwiftLibrary();
  25. private readonly SwiftGrid _grid = new SwiftGrid();
  26. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  27. private const string ViewFunctionId = "20211000";
  28. private const string UpdateKYCFunctionId = "20211010";
  29. private const string ViewFunctionIdAgent = "";
  30. private const string UpdateKYCFunctionIdAgent = "";
  31. protected void Page_Load(object sender, EventArgs e)
  32. {
  33. Authenticate();
  34. if (!IsPostBack)
  35. {
  36. PopulateDDL();
  37. GetStatic.PrintMessage(Page);
  38. startDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
  39. startDate.Attributes.Add("readonly", "readonly");
  40. string customerId = GetStatic.ReadQueryString("customerId", "");
  41. if (customerId != "")
  42. {
  43. HideSearchDiv();
  44. var customerName = GetCustomerName(customerId);
  45. lblCustName.InnerText = customerName;
  46. string custInfo = (customerId == "" ? hdnCustomerId.Value : customerId) + "," + (customerName);
  47. GetStatic.CallBackJs1(Page, "customerDoc", "PopulateAutoComplete('" + custInfo + "')");
  48. }
  49. }
  50. var custId = GetStatic.ReadQueryString("customerId", "");
  51. if (GetCustomerId() != "" || custId != "")
  52. {
  53. PopulateCustomerData();
  54. LoadGrid();
  55. }
  56. else
  57. {
  58. GetStatic.CallBackJs1(Page, "hide Div", "HideNecessaryDiv()");
  59. }
  60. DeleteRow();
  61. }
  62. private void PopulateCustomerData()
  63. {
  64. DataRow dr = _cd.GetCustomerData(GetStatic.GetUser(), GetCustomerId());
  65. if (dr != null)
  66. {
  67. string Name = dr["fullname"].ToString();
  68. string address = dr["address"].ToString();
  69. string mobile = dr["mobile"].ToString();
  70. customerName.Text = Name;
  71. customerAddress.Text = address;
  72. mobileNo.Text = mobile;
  73. }
  74. }
  75. private void Authenticate()
  76. {
  77. _swiftLib.CheckAuthentication(GetFunctionIdByUserType(ViewFunctionIdAgent, ViewFunctionId));
  78. save.Visible = _swiftLib.HasRight(GetFunctionIdByUserType(UpdateKYCFunctionIdAgent, UpdateKYCFunctionId));
  79. save.Enabled = _swiftLib.HasRight(GetFunctionIdByUserType(UpdateKYCFunctionIdAgent, UpdateKYCFunctionId));
  80. }
  81. public void PopulateDDL()
  82. {
  83. var user = GetStatic.GetUser();
  84. _sl.SetDDL(ref ddlStatus, "EXEC proc_online_dropDownList @flag='dropdownList',@parentId='7007',@user='" + user + "'", "valueId", "detailTitle", "", "Select..");
  85. _sl.SetDDL(ref ddlMethod, "EXEC proc_online_dropDownList @flag='dropdownList',@parentId='7008',@user='" + user + "'", "valueId", "detailTitle", "", "Select..");
  86. _sdd.SetDDL(ref ddlSearchBy, "exec proc_sendPageLoadData @flag='search-cust-by'", "VALUE", "TEXT", "", "");
  87. }
  88. protected void save_Click(object sender, EventArgs e)
  89. {
  90. DbResult _dbRes = new DbResult();
  91. if (!_swiftLib.HasRight(GetFunctionIdByUserType(UpdateKYCFunctionIdAgent, UpdateKYCFunctionId)))
  92. {
  93. _dbRes.SetError("1", "You are not authorized to Update Data", null);
  94. GetStatic.AlertMessage(this, _dbRes.Msg);
  95. return;
  96. }
  97. var selecteduserId = GetCustomerId();
  98. var kycmethod = ddlMethod.SelectedValue;
  99. var kycstatus = ddlStatus.SelectedValue;
  100. var selecteddate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
  101. var currentuser = GetStatic.GetUser();
  102. var remarkstext = remarks.Text;
  103. var trackNo = trackingNo.Text;
  104. JsonResponse jsonRes = _cd.InsertCustomerKYC(currentuser, selecteduserId, kycmethod, kycstatus, selecteddate, remarkstext, trackNo);
  105. startDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
  106. if (jsonRes.ResponseCode == "0")
  107. {
  108. try
  109. {
  110. CustomerDetails cd = _cd.GetUserDetails(selecteduserId);
  111. List<Mapping> bodyMappings = new List<Mapping>();
  112. bodyMappings.Add(new Mapping() { SValue = "CustomerName", SText = cd.FullName });
  113. bodyMappings.Add(new Mapping() { SValue = "RefCode", SText = cd.MembershipId });
  114. bodyMappings.Add(new Mapping() { SValue = "CustomerId", SText = cd.CustomerId.ToString() });
  115. bodyMappings.Add(new Mapping() { SValue = "UserId", SText = cd.MembershipId });
  116. bodyMappings.Add(new Mapping() { SValue = "FirstName", SText = cd.FirstName });
  117. bodyMappings.Add(new Mapping() { SValue = "MiddleName", SText = cd.MiddleName });
  118. bodyMappings.Add(new Mapping() { SValue = "LastName", SText = cd.LastName });
  119. bodyMappings.Add(new Mapping() { SValue = "MobileNo", SText = cd.Mobile });
  120. bodyMappings.Add(new Mapping() { SValue = "Address", SText = cd.Address });
  121. bodyMappings.Add(new Mapping() { SValue = "EMAIL_ID", SText = cd.Email });
  122. bodyMappings.Add(new Mapping() { SValue = "RegisteredDate", SText = cd.RegisteredDate.ToString() });
  123. SendNotificationRequestMobile request = new SendNotificationRequestMobile()
  124. {
  125. IsBulkNotification = false,
  126. UserName = cd.Email,
  127. ProcessId = "KYC_Verification_Completed",
  128. ProviderId = NotifyTemplate.KYC_VERIFICATION_EMAIL.ToString(),
  129. NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
  130. Template = NotifyTemplate.KYC_VERIFICATION_EMAIL,
  131. Recipients = new List<RecipientViewModel>()
  132. {
  133. new RecipientViewModel()
  134. {
  135. NotificationContent = new NotificationDTO() {
  136. Body = JsonConvert.SerializeObject(bodyMappings),
  137. //Title will be set by mapping json
  138. },
  139. Address= cd.Email
  140. }
  141. }
  142. };
  143. NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
  144. }
  145. catch (Exception ex)
  146. {
  147. GetStatic.LogError(ex);
  148. trackingNo.Text = "";
  149. GetStatic.AlertMessage(this, jsonRes.Msg);
  150. string custInfo = selecteduserId + "," + GetCustomerName(selecteduserId);
  151. GetStatic.CallBackJs1(Page, "customerDoc", "PopulateAutoComplete('" + custInfo + "')");
  152. LoadGrid();
  153. //HttpContext.Current.Session["message"] = _dbRes;
  154. //Response.Redirect(Request.RawUrl);
  155. }
  156. GetStatic.AlertMessage(this, jsonRes.Msg);
  157. }
  158. else
  159. {
  160. ddlMethod.SelectedValue = "";
  161. ddlStatus.SelectedValue = "";
  162. HttpContext.Current.Session["message"] = jsonRes;
  163. GetStatic.AlertMessage(this, jsonRes.Msg);
  164. }
  165. }
  166. public void LoadGrid()
  167. {
  168. _grid.FilterList = new List<GridFilter>
  169. {
  170. new GridFilter("detailTitle", "KYC Method", "1:EXEC proc_customerKYC @flag='dropdownListMethod'"),
  171. new GridFilter("detailTitle", "KYC Status", "1:EXEC proc_customerKYC @flag='dropdownListStatus'"),
  172. //new GridFilter("detailTitle", "KYC Method", "1:EXEC proc_customerKYC @flag='dropdownList'", "", "", true),
  173. //new GridFilter("kycStatus", "kycStatus", "1:" + "EXEC [proc_customerKYC] @flag = 's'"),
  174. ////new GridFilter("fromDate", "Registered From", "d"),
  175. //new GridFilter("toDate", "Registered To", "d"),
  176. };
  177. _grid.ColumnList = new List<GridColumn>
  178. {
  179. new GridColumn("kycStatus", "KYC Status", "", "T"),
  180. new GridColumn("trackingNo", "Tracking Number", "", "T"),
  181. new GridColumn("details", "Details(old Value:New Value)", "", "T"),
  182. new GridColumn("createdDate", "Modified Date", "", "D"),
  183. new GridColumn("createdBy", "Modified By", "", "T"),
  184. new GridColumn("kycMethod", "Method", "", "T"),
  185. new GridColumn("remarks", "Remarks", "", "T")
  186. };
  187. _grid.GridType = 1;
  188. _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  189. _grid.GridName = GridName;
  190. _grid.ShowPagingBar = true;
  191. _grid.AlwaysShowFilterForm = true;
  192. _grid.ShowFilterForm = false;
  193. _grid.RowIdField = "createdDate";
  194. _grid.ThisPage = "List.aspx"; ;
  195. _grid.InputPerRow = 4;
  196. _grid.GridMinWidth = 700;
  197. _grid.GridWidth = 100;
  198. _grid.IsGridWidthInPercent = true;
  199. _grid.AddPage = "Manage.aspx";
  200. _grid.AllowCustomLink = true;
  201. _grid.CustomLinkText = "&nbsp<btn class=\"btn btn-xs btn-danger\" onclick=\"Delete('@rowId','@kycStatus')\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Delete\"> <i class=\"fa fa-trash\"></i></btn>";
  202. _grid.CustomLinkVariables = "rowId,kycStatus";
  203. _grid.SortOrder = "DESC";
  204. _grid.SortBy = "createdDate";
  205. string sql = "EXEC [proc_customerKYC] @flag = 's', @customerId =" + _sl.FilterString(GetCustomerId());
  206. _grid.SetComma();
  207. rpt_grid.InnerHtml = _grid.CreateGrid(sql);
  208. }
  209. protected string GetCustomerId()
  210. {
  211. //string customerId= GetStatic.ReadQueryString("customerId", "");
  212. string customerId = hdnCustomerId.Value;
  213. if (customerId == "")
  214. {
  215. customerId = GetStatic.ReadQueryString("customerId", "");
  216. }
  217. return customerId;
  218. }
  219. private void DeleteRow()
  220. {
  221. string id = _grid.GetCurrentRowId(GridName);
  222. if (id == "")
  223. return;
  224. var user = GetStatic.GetUser();
  225. DbResult dbResult = _cd.DeleteCustomerKYC(id, user);
  226. if (dbResult.ErrorCode == "0")
  227. {
  228. LoadGrid();
  229. GetStatic.AlertMessage(this, dbResult.Msg);
  230. //HttpContext.Current.Session["message"] = dbResult;
  231. //Response.Redirect(Request.RawUrl);
  232. }
  233. else
  234. {
  235. HttpContext.Current.Session["message"] = dbResult;
  236. GetStatic.AlertMessage(this, dbResult.Msg);
  237. }
  238. string customerId = GetStatic.ReadQueryString("customerId", "");
  239. if (customerId != "")
  240. {
  241. GetStatic.CallBackJs1(Page, "Hide Search Div", "HideSearchDiv()");
  242. }
  243. }
  244. public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
  245. {
  246. return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
  247. }
  248. public string GetCustomerName(string custName)
  249. {
  250. var res = _cd.GetCustomerData(GetStatic.GetUser(), GetCustomerId());
  251. return res["fullName"].ToString();
  252. }
  253. public string HideSearchDiv()
  254. {
  255. var hide = GetStatic.ReadQueryString("hideSearchDiv", "").ToString();
  256. if (hide == "true")
  257. {
  258. displayOnlyOnEdit.Visible = false;
  259. }
  260. return null;
  261. }
  262. protected void delete_Click(object sender, EventArgs e)
  263. {
  264. var id = hdnRowId.Value;
  265. DbResult dbResult = _cd.DeleteCustomerKYC(id, GetStatic.GetUser());
  266. if (dbResult.ErrorCode == "0")
  267. {
  268. LoadGrid();
  269. GetStatic.AlertMessage(this, dbResult.Msg);
  270. //HttpContext.Current.Session["message"] = dbResult;
  271. //Response.Redirect(Request.RawUrl);
  272. }
  273. else
  274. {
  275. HttpContext.Current.Session["message"] = dbResult;
  276. GetStatic.AlertMessage(this, dbResult.Msg);
  277. }
  278. }
  279. }
  280. }