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.

598 lines
26 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using Swift.DAL.BL.Remit.ServiceCharge;
  9. using Swift.DAL.SwiftDAL;
  10. using Swift.web.Component.Grid;
  11. using Swift.web.Component.Grid.gridHelper;
  12. using Swift.web.Library;
  13. namespace Swift.web.Remit.Commission.ServiceCharge
  14. {
  15. public partial class Manage : Page
  16. {
  17. private const string ViewFunctionId = "20131000";
  18. private const string AddEditFunctionId = "20131010";
  19. private const string DeleteFunctionId = "20131020";
  20. private const string ApproveFunctionId = "20131030";
  21. private const string ApproveFunctionId2 = "20131035";
  22. protected const string GridName = "grd_sscDetail1";
  23. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  24. private readonly SwiftGrid grid = new SwiftGrid();
  25. private readonly SscMasterDao obj = new SscMasterDao();
  26. private readonly SscDetailDao sscdDao = new SscDetailDao();
  27. protected void Page_Load(object sender, EventArgs e)
  28. {
  29. if (!IsPostBack)
  30. {
  31. Authenticate();
  32. GetStatic.PrintMessage(Page);
  33. MakeNumericTextBox();
  34. if (GetId() > 0)
  35. {
  36. PopulateDataById();
  37. }
  38. else
  39. {
  40. PopulateDdl(null);
  41. PopulateData();
  42. }
  43. if (GetId() > 0)
  44. {
  45. tblCopySlab.Visible = true;
  46. LoadMaxAmount();
  47. }
  48. }
  49. if (GetId() > 0)
  50. LoadGrid(GetId().ToString());
  51. GetStatic.CallBackJs1(Page, "Populate", "PopulateDataById();");
  52. }
  53. private void MakeNumericTextBox()
  54. {
  55. Misc.MakeNumericTextbox(ref zipCode);
  56. }
  57. protected void btnSave_Click(object sender, EventArgs e)
  58. {
  59. Update();
  60. }
  61. private void LoadCountry(ref DropDownList ddl, string defaultValue)
  62. {
  63. string sql = "EXEC proc_countryMaster @flag = 'ocl'";
  64. _sdd.SetDDL(ref ddl, sql, "countryId", "countryName", defaultValue, "Select");
  65. }
  66. private void LoadSuperAgent(ref DropDownList ddl, string countryId, string defaultValue)
  67. {
  68. string sql = "EXEC proc_agentMaster @flag = 'sal', @agentCountry = " + _sdd.FilterString(countryId);
  69. _sdd.SetDDL(ref ddl, sql, "agentId", "agentName", defaultValue, "All");
  70. }
  71. private void LoadAgent(ref DropDownList ddl, string parentId, string countryId, string defaultValue)
  72. {
  73. string sql = "EXEC proc_agentMaster @flag = 'al', @parentId=" + _sdd.FilterString(parentId) +
  74. ", @agentCountry=" + _sdd.FilterString(countryId);
  75. _sdd.SetDDL(ref ddl, sql, "agentId", "agentName", defaultValue, "All");
  76. }
  77. private void LoadBranch(ref DropDownList ddl, string parentId, string defaultValue)
  78. {
  79. string sql = "EXEC proc_agentMaster @flag = 'bl', @parentId=" + _sdd.FilterString(parentId);
  80. _sdd.SetDDL(ref ddl, sql, "agentId", "agentName", defaultValue, "All");
  81. }
  82. private void LoadState(ref DropDownList ddl, string countryId, string defaultValue)
  83. {
  84. string sql = "EXEC proc_countryStateMaster @flag = 'csl', @countryId=" + _sdd.FilterString(countryId);
  85. _sdd.SetDDL(ref ddl, sql, "stateId", "stateName", defaultValue, "All");
  86. }
  87. private void LoadGroup(ref DropDownList ddl, string countryId, string groupCat, string defaultValue)
  88. {
  89. string sql = "EXEC proc_countryGroupMapping @flag = 'gl', @countryId = " + _sdd.FilterString(countryId) + ", @groupCat = " + _sdd.FilterString(groupCat);
  90. _sdd.SetDDL(ref ddl, sql, "groupId", "groupName", defaultValue, "Any");
  91. }
  92. private void LoadCurrency(ref DropDownList ddl, string countryId, string agentId, string defaultValue)
  93. {
  94. string sql = "";
  95. if(!string.IsNullOrEmpty(agentId))
  96. sql = "EXEC proc_agentCurrency @flag = 'acl', @agentId = " + _sdd.FilterString(agentId);
  97. else
  98. sql = "EXEC proc_countryCurrency @flag = 'l', @countryId = " + _sdd.FilterString(countryId);
  99. _sdd.SetDDL(ref ddl, sql, "currencyId", "currencyCode", defaultValue, "Select");
  100. }
  101. #region Amount Slab
  102. private void LoadGrid(string sscMasterId)
  103. {
  104. amountSlab.Visible = true;
  105. var allowApprove = _sdd.HasRight(ApproveFunctionId);
  106. var allowDelete = _sdd.HasRight(DeleteFunctionId);
  107. var popUpParam = "dialogHeight:400px;dialogWidth:500px;dialogLeft:300;dialogTop:100;center:yes";
  108. var ds = sscdDao.PopulateCommissionDetail(GetStatic.GetUser(), sscMasterId);
  109. var dt = ds.Tables[1];
  110. var html = new StringBuilder();
  111. html.Append("<table class=\"table table-responsive table-bordered table-striped\">");
  112. html.Append("<tr class=\"hdtitle\">");
  113. html.Append("<th class=\"hdtitle\" style=\"text-align: center;\"><a href=\"#\" onclick=\"ClearSelection('" + GridName + "');\">X</a></th>");
  114. html.Append("<th class=\"hdtitle\">Amount From</th>");
  115. html.Append("<th class=\"hdtitle\">Amount To</th>");
  116. html.Append("<th class=\"hdtitle\">Percent</th>");
  117. html.Append("<th class=\"hdtitle\">Min Amt</th>");
  118. html.Append("<th class=\"hdtitle\">Max Amt</th>");
  119. html.Append("<th class=\"hdtitle\"></th>");
  120. html.Append("</tr>");
  121. var i = 0;
  122. foreach (DataRow dr in dt.Rows)
  123. {
  124. html.Append(++i % 2 == 1 ? "<tr class=\"oddbg\" onMouseOver=\"this.className='GridOddRowOver'\" onMouseOut=\"this.className='oddbg'\">" : "<tr class=\"evenbg\" onMouseOver=\"this.className='GridEvenRowOver'\" onMouseOut=\"this.className='evenbg'\" >");
  125. html.Append("<td align=\"center\"><input type = \"checkbox\" value = \"" + dr["sscDetailId"] +
  126. "\" name =\"" + GridName + "_rowId\" onclick = \"EditSelected(this, '" + GridName + "', '" + dr["sscDetailId"] + "')\"" + AppendChkBoxProperties(dr["sscDetailId"].ToString()) + "></td>");
  127. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["fromAmt"].ToString(), "M") + "</td>");
  128. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["toAmt"].ToString(), "M") + "</td>");
  129. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["pcnt"].ToString(), "M") + "</td>");
  130. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["minAmt"].ToString(), "M") + "</td>");
  131. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["maxAmt"].ToString(), "M") + "</td>");
  132. html.Append("<td nowrap=\"nowrap\">");
  133. if (allowDelete)
  134. {
  135. html.AppendLine("<a title=\"Delete\" href=\"#\" onclick=\"DeleteCommissionDetail('" + dr["sscDetailId"] + "');\" /><img alt = \"Delete\" border = \"0\" title = \"Delete\" src=\"" + GetStatic.GetUrlRoot() + "/images/delete.gif\" /></a>");
  136. }
  137. if (allowApprove)
  138. {
  139. if (dr["haschanged"].ToString().ToUpper().Equals("Y"))
  140. {
  141. if (dr["modifiedby"].ToString() == GetStatic.GetUser())
  142. {
  143. var approveLink = "id=" + dr["sscDetailId"] + "&functionId=" + (ApproveFunctionId2 == "" ? ApproveFunctionId : ApproveFunctionId2) +
  144. "&functionId2=" + ApproveFunctionId + "&modBy=" + dr["modifiedby"];
  145. var approvePage = GetStatic.GetUrlRoot() + "/ViewChanges.aspx?" + approveLink;
  146. var jsText = "onclick = \"PopUp('" + GridName + "','" + approvePage + "','" + popUpParam + "');\"";
  147. html.AppendLine("&nbsp;<a title = \"View Changes\" href=\"javascript:void(0)\" " + jsText + "\"><img alt = \"Waiting for Approval\" border = \"0\" title = \"Waiting for Approval\" src=\"" + GetStatic.GetUrlRoot() + "/images/wait-icon.png\" /></a>");
  148. }
  149. else
  150. {
  151. var approveLink = "id=" + dr["sscDetailId"] + "&functionId=" + (ApproveFunctionId2 == "" ? ApproveFunctionId : ApproveFunctionId2) +
  152. "&functionId2=" + ApproveFunctionId;
  153. var approvePage = GetStatic.GetUrlRoot() + "/ViewChanges.aspx?" + approveLink;
  154. var jsText = "onclick = \"PopUp('" + GridName + "','" + approvePage + "','" + popUpParam + "');";
  155. html.AppendLine("&nbsp;<a title = \"View Changes\" href=\"javascript:void(0)\" " + jsText + "\"><img alt = \"View Changes\" border = \"0\" title = \"View Changes\" src=\"" + GetStatic.GetUrlRoot() + "/images/view-changes.jpg\" /></a>");
  156. }
  157. }
  158. }
  159. html.Append("</td>");
  160. html.Append("</tr>");
  161. }
  162. html.Append("<tr>");
  163. html.Append("<td colspan=\"5\">Add/Edit Amount Details &nbsp;<input type=\"button\" class='btn btn-primary' value=\"Add New\" onclick=\"AddNew();\" /></td>");
  164. html.Append("</tr>");
  165. html.Append("<tr class=\"evenbg\">");
  166. html.Append("<td></td>");
  167. html.Append("<td class=\"alignRight\"><input id=\"fromAmt1\" type=\"text\" class=\"textbox\" onkeydown=\"return numericOnly(this, (event?event:evt), true);\"/></td>");
  168. html.Append("<td class=\"alignRight\"><input id=\"toAmt1\" type=\"text\" class=\"textbox\" onkeydown=\"return numericOnly(this, (event?event:evt), true);\"/></td>");
  169. html.Append("<td class=\"alignRight\"><input id=\"pcnt1\" type=\"text\" class=\"textbox\" onblur=\"ManageDetail1('pcnt1','minAmt1','maxAmt1');\" onkeydown=\"return numericOnly(this, (event?event:evt), true);\"/></td>");
  170. html.Append("<td class=\"alignRight\"><input id=\"minAmt1\" type=\"text\" class=\"textbox\" onblur=\"ManageDetail2('pcnt1','minAmt1','maxAmt1');\" onkeydown=\"return numericOnly(this, (event?event:evt), true);\"/></td>");
  171. html.Append("<td class=\"alignRight\"><input id=\"maxAmt1\" type=\"text\" class=\"textbox\" onkeydown=\"return numericOnly(this, (event?event:evt), true);\"/></td>");
  172. html.Append("<td><input id=\"btnSave1\" class='btn btn-primary' type=\"button\" value=\"Save\" onclick=\"Save();\" /></td>");
  173. html.Append("</tr>");
  174. html.Append("</table>");
  175. html.Append("<input type = \"submit\" id = \"" + GridName + "_submitButton\" name = \"" + GridName + "_submitButton\" style=\"display:none\">");
  176. rpt_grid.InnerHtml = html.ToString();
  177. }
  178. private string AppendChkBoxProperties(string id)
  179. {
  180. var selectionCheckBoxList = GetStatic.ReadFormData(GridName + "_rowId", "");
  181. var valueList = selectionCheckBoxList.Split(',');
  182. if (valueList.Any(s => s.ToUpper().Equals(id.ToUpper())))
  183. {
  184. return "checked = \"checked\"";
  185. }
  186. return "";
  187. }
  188. private void PopulateCommissionDetailById()
  189. {
  190. DataRow dr = sscdDao.SelectById(GetStatic.GetUser(), hddSscDetailId.Value);
  191. if (dr == null)
  192. return;
  193. fromAmt.Value = GetStatic.FormatData(dr["fromAmt"].ToString(), "M");
  194. toAmt.Value = GetStatic.FormatData(dr["toAmt"].ToString(), "M");
  195. pcnt.Value = GetStatic.FormatData(dr["pcnt"].ToString(), "M");
  196. minAmt.Value = GetStatic.FormatData(dr["minAmt"].ToString(), "M");
  197. maxAmt.Value = GetStatic.FormatData(dr["maxAmt"].ToString(), "M");
  198. GetStatic.CallBackJs1(Page, "Populate Data", "PopulateDataById();");
  199. }
  200. private void DeleteRow()
  201. {
  202. if (string.IsNullOrEmpty(hddSscDetailId.Value))
  203. return;
  204. DbResult dbResult = sscdDao.Delete(GetStatic.GetUser(), hddSscDetailId.Value);
  205. ManageMessage2(dbResult);
  206. }
  207. private void UpdateCommissionDetail()
  208. {
  209. DbResult dbResult = sscdDao.Update(GetStatic.GetUser()
  210. , hddSscDetailId.Value
  211. , GetId().ToString()
  212. , fromAmt.Value
  213. , toAmt.Value
  214. , pcnt.Value
  215. , minAmt.Value
  216. , maxAmt.Value);
  217. ManageMessage2(dbResult);
  218. }
  219. private void ManageMessage2(DbResult dbResult)
  220. {
  221. GetStatic.SetMessage(dbResult);
  222. GetStatic.PrintMessage(Page);
  223. if (dbResult.ErrorCode == "0")
  224. {
  225. LoadGrid(GetId().ToString());
  226. AddNew();
  227. }
  228. }
  229. private void AddNew()
  230. {
  231. LoadMaxAmount();
  232. hddSscDetailId.Value = "";
  233. toAmt.Value = "";
  234. pcnt.Value = "";
  235. minAmt.Value = "";
  236. maxAmt.Value = "";
  237. GetStatic.CallBackJs1(Page, "New Record", "NewRecord();");
  238. }
  239. private void LoadMaxAmount()
  240. {
  241. double maxAmount = _sdd.GetMaxAmount("sscMasterId", GetId().ToString(), "sscDetail");
  242. double startAmt = maxAmount + 0.01;
  243. fromAmt.Value = startAmt.ToString();
  244. }
  245. protected void btnSaveDetail_Click(object sender, EventArgs e)
  246. {
  247. UpdateCommissionDetail();
  248. }
  249. protected void btnEditDetail_Click(object sender, EventArgs e)
  250. {
  251. PopulateCommissionDetailById();
  252. }
  253. protected void btnDeleteDetail_Click(object sender, EventArgs e)
  254. {
  255. DeleteRow();
  256. }
  257. protected void btnAddNew_Click(object sender, EventArgs e)
  258. {
  259. AddNew();
  260. }
  261. #endregion
  262. #region Copy Module
  263. private void LoadSlabGridForCopy(string scSendMasterId)
  264. {
  265. if (scSendMasterId == "")
  266. {
  267. divSlabgrid.Visible = false;
  268. rpt_slabgrid.InnerHtml = "";
  269. return;
  270. }
  271. divSlabgrid.Visible = true;
  272. var ds = sscdDao.PopulateCommissionDetail(GetStatic.GetUser(), scSendMasterId);
  273. var dt = ds.Tables[1];
  274. var html = new StringBuilder();
  275. html.Append("<table class=\"table table-responsive table-bordered table-striped\">");
  276. html.Append("<tr class=\"hdtitle\">");
  277. html.Append("<th class=\"hdtitle\">Amount From</th>");
  278. html.Append("<th class=\"hdtitle\">Amount To</th>");
  279. html.Append("<th class=\"hdtitle\">Percent</th>");
  280. html.Append("<th class=\"hdtitle\">Min Amt</th>");
  281. html.Append("<th class=\"hdtitle\">Max Amt</th>");
  282. html.Append("</tr>");
  283. var i = 0;
  284. foreach (DataRow dr in dt.Rows)
  285. {
  286. html.Append(++i % 2 == 1 ? "<tr class=\"oddbg\" onMouseOver=\"this.className='GridOddRowOver'\" onMouseOut=\"this.className='oddbg'\">" : "<tr class=\"evenbg\" onMouseOver=\"this.className='GridEvenRowOver'\" onMouseOut=\"this.className='evenbg'\" >");
  287. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["fromAmt"].ToString(), "M") + "</td>");
  288. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["toAmt"].ToString(), "M") + "</td>");
  289. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["pcnt"].ToString(), "M") + "</td>");
  290. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["minAmt"].ToString(), "M") + "</td>");
  291. html.Append("<td class=\"alignRight\">" + GetStatic.FormatData(dr["maxAmt"].ToString(), "M") + "</td>");
  292. html.Append("</tr>");
  293. }
  294. html.Append("</table>");
  295. rpt_slabgrid.InnerHtml = html.ToString();
  296. }
  297. protected void commissionSlab_SelectedIndexChanged(object sender, EventArgs e)
  298. {
  299. LoadSlabGridForCopy(commissionSlab.Text);
  300. commissionSlab.Focus();
  301. }
  302. private void CopySlab()
  303. {
  304. var dbResult = sscdDao.CopySlab(GetStatic.GetUser(), commissionSlab.Text, GetId().ToString());
  305. ManageMessage(dbResult);
  306. }
  307. protected void btnCopySlab_Click(object sender, EventArgs e)
  308. {
  309. CopySlab();
  310. }
  311. #endregion
  312. #region Control Methods
  313. protected void sCountry_SelectedIndexChanged(object sender, EventArgs e)
  314. {
  315. LoadSuperAgent(ref ssAgent, sCountry.Text, "");
  316. LoadAgent(ref sAgent, ssAgent.Text, sCountry.Text, "");
  317. LoadState(ref state, sCountry.Text, "");
  318. LoadCurrency(ref baseCurrency, sCountry.Text, sAgent.Text, "");
  319. LoadGroup(ref agentGroup, sCountry.Text, "6300", "");
  320. sCountry.Focus();
  321. }
  322. protected void ssAgent_SelectedIndexChanged(object sender, EventArgs e)
  323. {
  324. LoadAgent(ref sAgent, ssAgent.Text, sCountry.Text, "");
  325. ssAgent.Focus();
  326. }
  327. protected void sAgent_SelectedIndexChanged(object sender, EventArgs e)
  328. {
  329. LoadBranch(ref sBranch, sAgent.Text, "");
  330. //LoadCurrency(ref baseCurrency, sCountry.Text, sAgent.Text, "");
  331. sAgent.Focus();
  332. }
  333. protected void rCountry_SelectedIndexChanged(object sender, EventArgs e)
  334. {
  335. LoadSuperAgent(ref rsAgent, rCountry.Text, "");
  336. LoadAgent(ref rAgent, rsAgent.Text, rCountry.Text, "");
  337. LoadState(ref rState, rCountry.Text, "");
  338. LoadGroup(ref rAgentGroup, rCountry.Text, "6400", "");
  339. rCountry.Focus();
  340. }
  341. protected void rsAgent_SelectedIndexChanged(object sender, EventArgs e)
  342. {
  343. LoadAgent(ref rAgent, rsAgent.Text, rCountry.Text, "");
  344. rsAgent.Focus();
  345. }
  346. protected void rAgent_SelectedIndexChanged(object sender, EventArgs e)
  347. {
  348. LoadBranch(ref rBranch, rAgent.Text, "");
  349. rAgent.Focus();
  350. }
  351. #endregion
  352. #region QueryString
  353. private long GetId()
  354. {
  355. return GetStatic.ReadNumericDataFromQueryString("sscMasterId");
  356. }
  357. protected string GetSCountryId()
  358. {
  359. return GetStatic.ReadNumericDataFromQueryString("sCountry").ToString();
  360. }
  361. protected string GetRCountryId()
  362. {
  363. return GetStatic.ReadNumericDataFromQueryString("rCountry").ToString();
  364. }
  365. protected string GetSsAgentId()
  366. {
  367. return GetStatic.ReadNumericDataFromQueryString("ssAgent").ToString();
  368. }
  369. protected string GetRsAgentId()
  370. {
  371. return GetStatic.ReadNumericDataFromQueryString("rsAgent").ToString();
  372. }
  373. protected string GetSAgent()
  374. {
  375. return GetStatic.ReadNumericDataFromQueryString("sAgent").ToString();
  376. }
  377. protected string GetRAgent()
  378. {
  379. return GetStatic.ReadNumericDataFromQueryString("rAgent").ToString();
  380. }
  381. protected string GetTranType()
  382. {
  383. return GetStatic.ReadNumericDataFromQueryString("tranType").ToString();
  384. }
  385. private void Authenticate()
  386. {
  387. _sdd.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId + "," + DeleteFunctionId);
  388. btnSave.Visible = _sdd.HasRight(AddEditFunctionId);
  389. }
  390. #endregion
  391. #region Populate DropDown
  392. private void PopulateDdl(DataRow dr)
  393. {
  394. _sdd.SetDDL(ref commissionSlab, "EXEC proc_sscMaster @flag = 'cl'", "sscMasterId", "code", "", "Select");
  395. LoadCountry(ref sCountry, GetStatic.GetRowData(dr, "sCountry"));
  396. LoadCountry(ref rCountry, GetStatic.GetRowData(dr, "rCountry"));
  397. LoadSuperAgent(ref ssAgent, sCountry.Text, GetStatic.GetRowData(dr, "ssAgent"));
  398. LoadSuperAgent(ref rsAgent, rCountry.Text, GetStatic.GetRowData(dr, "rsAgent"));
  399. LoadAgent(ref sAgent, ssAgent.Text, sCountry.Text, GetStatic.GetRowData(dr, "sAgent"));
  400. LoadAgent(ref rAgent, rsAgent.Text, rCountry.Text, GetStatic.GetRowData(dr, "rAgent"));
  401. LoadCurrency(ref baseCurrency, sCountry.Text, "", GetStatic.GetRowData(dr, "baseCurrency"));
  402. LoadBranch(ref sBranch, sAgent.Text, GetStatic.GetRowData(dr, "sBranch"));
  403. LoadBranch(ref rBranch, rAgent.Text, GetStatic.GetRowData(dr, "rBranch"));
  404. _sdd.SetDDL(ref tranType, "EXEC proc_serviceTypeMaster @flag = 'l2'", "serviceTypeId", "typeTitle",
  405. GetStatic.GetRowData(dr, "tranType"), "All");
  406. LoadState(ref state, sCountry.Text, GetStatic.GetRowData(dr, "state"));
  407. LoadState(ref rState, rCountry.Text, GetStatic.GetRowData(dr, "rState"));
  408. LoadGroup(ref agentGroup, sCountry.Text, "6300", GetStatic.GetRowData(dr, "agentGroup"));
  409. LoadGroup(ref rAgentGroup, rCountry.Text, "6400", GetStatic.GetRowData(dr, "rAgentGroup"));
  410. }
  411. private void PopulateData()
  412. {
  413. string sCountryId = GetSCountryId();
  414. string rCountryId = GetRCountryId();
  415. string ssAgentId = GetSsAgentId();
  416. string rsAgentId = GetRsAgentId();
  417. string sAgentId = GetSAgent();
  418. string rAgentId = GetRAgent();
  419. string tranTypeId = GetTranType();
  420. if (sCountryId != "0")
  421. {
  422. sCountry.SelectedValue = sCountryId;
  423. LoadAgent(ref sAgent, ssAgent.Text, sCountryId, "");
  424. LoadState(ref state, sCountryId, "");
  425. }
  426. if (rCountryId != "0")
  427. {
  428. rCountry.SelectedValue = rCountryId;
  429. LoadAgent(ref rAgent, rsAgent.Text, rCountryId, "");
  430. LoadState(ref rState, rCountryId, "");
  431. }
  432. if (ssAgentId != "0")
  433. {
  434. ssAgent.SelectedValue = ssAgentId;
  435. LoadAgent(ref sAgent, ssAgentId, sCountry.Text, "");
  436. }
  437. if (rsAgentId != "0")
  438. {
  439. rsAgent.SelectedValue = rsAgentId;
  440. LoadAgent(ref rAgent, rsAgentId, rCountry.Text, "");
  441. }
  442. if (sAgentId != "0")
  443. {
  444. sAgent.SelectedValue = sAgentId;
  445. LoadBranch(ref sBranch, sAgentId, "");
  446. }
  447. if (rAgentId != "0")
  448. {
  449. rAgent.SelectedValue = rAgentId;
  450. LoadBranch(ref rBranch, rAgentId, "");
  451. }
  452. if (tranTypeId != "0")
  453. {
  454. tranType.SelectedValue = tranTypeId;
  455. }
  456. }
  457. #endregion
  458. #region Method
  459. private void PopulateDataById()
  460. {
  461. DataRow dr = obj.SelectById(GetStatic.GetUser(), GetId().ToString());
  462. if (dr == null)
  463. return;
  464. PopulateDdl(dr);
  465. code.Text = dr["code"].ToString();
  466. description.Text = dr["description"].ToString();
  467. zipCode.Text = dr["zip"].ToString();
  468. rZipCode.Text = dr["rZip"].ToString();
  469. effectiveFrom.Text = dr["effFrom"].ToString();
  470. effectiveTo.Text = dr["effTo"].ToString();
  471. //DisableField();
  472. }
  473. private void DisableField()
  474. {
  475. sCountry.Enabled = false;
  476. ssAgent.Enabled = false;
  477. sAgent.Enabled = false;
  478. sBranch.Enabled = false;
  479. rCountry.Enabled = false;
  480. rsAgent.Enabled = false;
  481. rAgent.Enabled = false;
  482. rBranch.Enabled = false;
  483. }
  484. private void Update()
  485. {
  486. DbResult dbResult = obj.Update(GetStatic.GetUser()
  487. , GetId().ToString()
  488. , code.Text
  489. , description.Text
  490. , sCountry.SelectedValue
  491. , ssAgent.SelectedValue
  492. , sAgent.SelectedValue
  493. , sBranch.SelectedValue
  494. , rCountry.SelectedValue
  495. , rsAgent.SelectedValue
  496. , rAgent.SelectedValue
  497. , rBranch.SelectedValue
  498. , state.Text
  499. , zipCode.Text
  500. , agentGroup.SelectedValue
  501. , rState.Text
  502. , rZipCode.Text
  503. , rAgentGroup.Text
  504. , baseCurrency.Text
  505. , tranType.SelectedValue
  506. , ""
  507. , ""
  508. , ""
  509. , ""
  510. , effectiveFrom.Text
  511. , effectiveTo.Text);
  512. ManageMessage(dbResult);
  513. }
  514. private void ManageMessage(DbResult dbResult)
  515. {
  516. GetStatic.SetMessage(dbResult);
  517. if (dbResult.ErrorCode == "0")
  518. {
  519. Response.Redirect("Manage.aspx?sCountry=" + GetSCountryId() + "&rCountry=" + GetRCountryId() +
  520. "&ssAgent=" + GetSsAgentId() + "&rsAgent=" + GetRsAgentId() + "&sAgent=" + GetSAgent() +
  521. "&rAgent=" + GetRAgent() + "&tranType=" + GetTranType() + "&sscMasterId=" +
  522. dbResult.Id);
  523. }
  524. else
  525. {
  526. GetStatic.PrintMessage(Page);
  527. }
  528. }
  529. #endregion
  530. }
  531. }