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.

261 lines
10 KiB

  1. using Swift.DAL.BL.Remit.Administration.Customer;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Data;
  6. using System.Web.UI.WebControls;
  7. namespace Swift.web.AgentPanel.Administration.CustomerSetup
  8. {
  9. public partial class Manage : System.Web.UI.Page
  10. {
  11. private const string GridName = "CustomerRefund";
  12. private const string ViewFunctionId = "40133900";
  13. private const string AddEditFunctionId = "40133910";
  14. private const string DeleteFunctionId = "40133920";
  15. private const string ApproveFunctionId = "40133920";
  16. private readonly StaticDataDdl _sl = new StaticDataDdl();
  17. private readonly CustomerSetupIntlDao _obj = new CustomerSetupIntlDao();
  18. protected void Page_Load(object sender, EventArgs e)
  19. {
  20. Authenticate();
  21. GetStatic.PrintMessage(Page);
  22. if (!IsPostBack)
  23. {
  24. MakeNumericTextbox();
  25. ManageSetting();
  26. }
  27. }
  28. private void ManageSetting()
  29. {
  30. if (GetId() > 0)
  31. PopulateDataById();
  32. else
  33. PopulateDdl(null);
  34. }
  35. private void Authenticate()
  36. {
  37. _sl.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId + "," + DeleteFunctionId);
  38. btnSave.Visible = _sl.HasRight(AddEditFunctionId);
  39. }
  40. private bool ClientValidation()
  41. {
  42. if (dob.Text == "")
  43. return true;
  44. DateTime _dob = Convert.ToDateTime(dob.Text);
  45. if (_dob > DateTime.Now)
  46. {
  47. lblDobChk.Text = "Invalid Date";
  48. dob.Focus();
  49. return false;
  50. }
  51. if ((DateTime.Now.Year - _dob.Year) < 18)
  52. {
  53. lblDobChk.Text = "Customer not Eligible";
  54. dob.Focus();
  55. return false;
  56. }
  57. return true;
  58. }
  59. private void MakeNumericTextbox()
  60. {
  61. Misc.MakeNumericTextbox(ref mobile);
  62. Misc.MakeNumericTextbox(ref homePhone);
  63. Misc.MakeNumericTextbox(ref workPhone);
  64. Misc.MakeNumericTextbox(ref zipCode);
  65. }
  66. #region Method
  67. protected long GetId()
  68. {
  69. return GetStatic.ReadNumericDataFromQueryString("customerId");
  70. }
  71. protected string GetCustomerName()
  72. {
  73. return "Customer Name : " + _obj.GetCustomerName(GetId().ToString());
  74. }
  75. protected string GetSection()
  76. {
  77. return GetStatic.ReadQueryString("section", "");
  78. }
  79. private void PopulateDdl(DataRow dr)
  80. {
  81. _sl.SetDDL(ref country, "EXEC proc_countryMaster @flag = 'l2', @user = " + _sl.FilterString(GetStatic.GetUser()), "countryId", "countryName",
  82. GetStatic.GetRowData(dr, "country"), "Select");
  83. _sl.SetDDL(ref occupation, "EXEC proc_dropDownLists @flag = 'occupation'", "occupationId", "detailTitle", GetStatic.GetRowData(dr, "occupation"), "Select");
  84. _sl.SetStaticDdl(ref district, "3", GetStatic.GetRowData(dr, "district"), "Select");
  85. LoadRegionSettings(country.Text);
  86. _sl.SetDDL(ref nativeCountry, "EXEC proc_countryMaster @flag = 'l'", "countryId", "countryName",
  87. GetStatic.GetRowData(dr, "nativeCountry"), "Select");
  88. _sl.SetStaticDdl(ref gender, "4", GetStatic.GetRowData(dr, "gender"), "Select");
  89. _sl.SetStaticDdl(ref customerType, "4700", GetStatic.GetRowData(dr, "customerType"), "Select");
  90. LoadState(ref state, country.Text, GetStatic.GetRowData(dr, "state"));
  91. LoadDistrict(ref district, state.Text, GetStatic.GetRowData(dr, "district"));
  92. _sl.SetDDL(ref ddlRelation, "EXEC proc_countryMaster @flag = '321', @user = " + _sl.FilterString(GetStatic.GetUser()), "valueId", "detailTitle",
  93. GetStatic.GetRowData(dr, "relationId"), "Select");
  94. _sl.SetDDL(ref idType, "EXEC proc_currencyMaster @flag = 'id'", "valueId", "detailTitle",
  95. GetStatic.GetRowData(dr, "idType"), "Select");
  96. }
  97. private void PopulateDataById()
  98. {
  99. DataRow dr = _obj.SelectById(GetStatic.GetUser(), GetId().ToString());
  100. if (dr == null)
  101. return;
  102. membershipId.Text = dr["membershipId"].ToString();
  103. firstName.Text = dr["firstName"].ToString();
  104. middleName.Text = dr["middleName"].ToString();
  105. lastName1.Text = dr["lastName1"].ToString();
  106. lastName2.Text = dr["lastName2"].ToString();
  107. address.Text = dr["address"].ToString();
  108. state.Text = dr["state"].ToString();
  109. zipCode.Text = dr["zipCode"].ToString();
  110. city.Text = dr["city"].ToString();
  111. email.Text = dr["email"].ToString();
  112. homePhone.Text = dr["homePhone"].ToString();
  113. workPhone.Text = dr["workPhone"].ToString();
  114. mobile.Text = dr["mobile"].ToString();
  115. dob.Text = dr["dob1"].ToString();
  116. isBlackListed.Text = dr["isBlackListed"].ToString();
  117. relationFullName.Text = dr["relativeName"].ToString();
  118. companyName.Text = dr["companyName"].ToString();
  119. idNumber.Text = dr["idNumber"].ToString();
  120. if (!string.IsNullOrWhiteSpace(dr["memberIDissuedDate"].ToString()))
  121. {
  122. midBox.Visible = true;
  123. membershipId.ReadOnly = true;
  124. isMemberIssued.Visible = false;
  125. isMemberIssued.Checked = false;
  126. }
  127. else
  128. {
  129. membershipId.ReadOnly = false;
  130. midBox.Visible = false;
  131. isMemberIssued.Visible = true;
  132. isMemberIssued.Checked = false;
  133. }
  134. PopulateDdl(dr);
  135. if (GetStatic.GetAgentType() == "2904" || GetStatic.GetIsActAsBranch().ToUpper() == "Y")
  136. {
  137. if (string.IsNullOrEmpty(dr["approvedBy"].ToString()) && dr["createdBy"].ToString() == GetStatic.GetUser())
  138. {
  139. btnSave.Visible = true;
  140. }
  141. else
  142. {
  143. btnSave.Visible = false;
  144. }
  145. }
  146. }
  147. private void Update()
  148. {
  149. if (!ClientValidation())
  150. return;
  151. var isMemberIssue = GetStatic.GetBoolToChar(isMemberIssued.Checked);
  152. if (isMemberIssue == "Y" && string.IsNullOrWhiteSpace(membershipId.Text))
  153. {
  154. GetStatic.PrintErrorMessage(Page, "Member Id should not be blank");
  155. return;
  156. }
  157. DbResult dbResult = _obj.Update(GetStatic.GetUser(), GetId().ToString(), "0", membershipId.Text,
  158. firstName.Text, middleName.Text, lastName1.Text, lastName2.Text,
  159. country.SelectedValue, address.Text, state.Text, zipCode.Text, district.Text,
  160. city.Text, email.Text, homePhone.Text, workPhone.Text, mobile.Text,
  161. nativeCountry.SelectedValue, dob.Text, occupation.Text, gender.Text, customerType.Text,
  162. isBlackListed.Text, ddlRelation.Text, relationFullName.Text, companyName.Text,
  163. isMemberIssue, GetStatic.GetAgent(), GetStatic.GetBranch(), idType.Text, idNumber.Text);
  164. ManageMessage(dbResult);
  165. }
  166. private void ManageMessage(DbResult dbResult)
  167. {
  168. GetStatic.SetMessage(dbResult);
  169. if (dbResult.ErrorCode != "0")
  170. {
  171. GetStatic.AlertMessage(Page, dbResult.Msg);
  172. return;
  173. }
  174. else
  175. Response.Redirect("List.aspx");
  176. }
  177. private void LoadState(ref DropDownList ddl, string countryId, string defaultValue)
  178. {
  179. string sql = "EXEC proc_countryStateMaster @flag = 'csl', @countryId = " + _sl.FilterString(countryId);
  180. _sl.SetDDL(ref ddl, sql, "stateId", "stateName", defaultValue, "Select");
  181. }
  182. protected void LoadRegionSettings(string countryId)
  183. {
  184. if (countryId == "Nepal")
  185. {
  186. lblRegionType.Text = "Zone";
  187. pnlDistrict.Visible = true;
  188. pnlZip.Visible = false;
  189. }
  190. else
  191. {
  192. lblRegionType.Text = "State";
  193. pnlDistrict.Visible = false;
  194. pnlZip.Visible = true;
  195. }
  196. }
  197. private void LoadDistrict(ref DropDownList ddl, string zone, string defaultValue)
  198. {
  199. string sql = "EXEC proc_zoneDistrictMap @flag = 'l', @zone = " + _sl.FilterString(zone);
  200. _sl.SetDDL(ref ddl, sql, "districtId", "districtName", defaultValue, "Select");
  201. }
  202. #endregion Method
  203. #region Element Method
  204. protected void country_SelectedIndexChanged(object sender, EventArgs e)
  205. {
  206. LoadState(ref state, country.Text, "");
  207. LoadRegionSettings(country.SelectedItem.Text);
  208. country.Focus();
  209. }
  210. protected void state_SelectedIndexChanged(object sender, EventArgs e)
  211. {
  212. LoadDistrict(ref district, state.Text, "");
  213. state.Focus();
  214. }
  215. protected void btnSave_Click(object sender, EventArgs e)
  216. {
  217. Update();
  218. }
  219. protected void btnBack_Click(object sender, EventArgs e)
  220. {
  221. if (GetSection() == "")
  222. Response.Redirect("List.aspx");
  223. else
  224. GetStatic.CallBackJs1(Page, "Close Window", "window.close();");
  225. }
  226. #endregion Element Method
  227. protected void isMemberIssued_CheckedChanged(object sender, EventArgs e)
  228. {
  229. midBox.Visible = isMemberIssued.Checked ? true : false;
  230. }
  231. }
  232. }