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.

299 lines
14 KiB

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