C#

Parent Previous Next

Get Deposit Accounts Details



1. getDepositAccountDetailsClass.cs



These four packages are required to be used.









Step 1. Create class file to store content of the web response.










2. getDepositAccountDetails.aspx.cs



These 13 packages are required to be used.








Code in Common



(1). Check if user id and password is inside session. When the user id and password is inside user session, it will automatically populate into the user id and pin textbox, so that the user need not manually type his user id and password repeatedly.









Step 2. Store Details which entered by the user. If user id, password, and OTP exist in session, user need not enter again (refer to common staff).








Step 3. Create URL which will be post to the server. User inputs need to be stored in the class created, and serialize into JSON format. In this function, only header is needed.









Step 4. Post to the server, and store response. URL is sent using web request function, and a response will be send back from the server. The response need to be deserialized into the ‘getDepositAccountDetails’ class.









Step 5. Obtain error code. If error code is ‘010000’ which means invocation successful, populate attributes of the ‘creditTransfer’ class into the label. If error code is '010041', it means OTP has expired, and we will use the newOTP() function to prompt the user for the OTP again. Else, we will display the ErrorText and ErrorDetails.


The newOTP() function can be referred to under Common Stuff Section









Overview of  getDepositAccountDetailsClass.cs



using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;


namespace Demo

{

   public class AccountDetailRootObject

   {

       public AccountContent Content { get; set; }

   }


   public class AccountContent

   {

       public ServiceResponse ServiceResponse { get; set; }

   }


   public class ServiceResponse

   {

       public DepositAccount DepositAccount { get; set; }

       public ServiceRespHeader ServiceRespHeader { get; set; }

   }


   public class DepositAccount

   {

       public string HomeBranch { get; set; }

       public Casaaccount Casaaccount { get; set; }

       public string AssignedAccountForAccountManagementFeeDeduction { get; set; }

       public string AccountOpenDate { get; set; }

       public string Balance { get; set; }

       public string CurrentStatus { get; set; }

       public string Currency { get; set; }

       public string CustomerID { get; set; }

       public string MaturityDate { get; set; }

       public string IsServiceChargeWaived { get; set; }

       public string InterestRate { get; set; }

       public AccountMaintenancehistory Maintenancehistory { get; set; }

       public string OfficerID { get; set; }

       public string Narrative { get; set; }

       public string PenaltyRate { get; set; }

       public Product Product { get; set; }

   }


   public class Casaaccount

   {

       public object DueInterestAmount { get; set; }

       public object AccrueInterestAmount { get; set; }

       public object AccountCloseDate { get; set; }

       public string DepositTerm { get; set; }

       public string IsRestricted { get; set; }

       public string MinorStatus { get; set; }

       public string InterestPayoutAccount { get; set; }

       public string MinimumAmount { get; set; }

       public string ParentAccountFlag { get; set; }

   }


   public class AccountMaintenancehistory

   {

       public string LastMaintenanceOfficer { get; set; }

       public string LastTransactionBranch { get; set; }

   }


   public class Product

   {

       public string DateBasisForRate { get; set; }

       public string ProductName { get; set; }

       public string CompoundInterestRateBasis { get; set; }

       public string ProductID { get; set; }

       public string RateChartCode { get; set; }

   }


   public class ServiceRespHeader

   {

       public string ErrorText { get; set; }

       public object ErrorDetails { get; set; }

       public string GlobalErrorID { get; set; }

   }

}


Download






Overview of  getDepositAccountDetails.aspx.cs



using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using DotNetOpenAuth.OAuth2;

using Newtonsoft.Json;

using System.Collections.Specialized;

using System.Configuration;

using System.Net;

using System.IO;

using System.Windows.Forms;


namespace Demo

{

   public partial class getDepositAccountDetails : System.Web.UI.Page

   {

       protected void Page_Load(object sender, EventArgs e)

       {

           if (Session["userid"] != null)

           {

               txtUserID.Text = (string)Session["userid"];

               txtPassword.Text = (string)Session["pin"];

           }

       }


       protected void btnSend_Click(object sender, EventArgs e)

       {

           try

           {

               string userID = txtUserID.Text;

               Session["userid"] = userID;

               string pin = txtPassword.Text;

               Session["pin"] = pin;

               string accountNo = txtAccountID.Text;

               string otp;

               if (Session["otp"] == null)

               {

                   otp = "";

               }

               else

               {

                   otp = Session["otp"].ToString();

               }


               var header = new HeaderJson();

               header.userID = userID;

               header.PIN = pin;

               header.OTP = "123455";

               header.serviceName = "getDepositAccountDetails";


               var headerObj = new HeaderJsonObject();

               headerObj.Header = header;


               string headerJson = JsonConvert.SerializeObject(headerObj);


               var content = new ContentJson();

               content.accountID = accountNo;


               var contentObj = new ContentJsonObject();

               contentObj.Content = content;


               string contentJson = JsonConvert.SerializeObject(contentObj);


               string url = "http://tbankonline.com/SMUtBank_API/Gateway?Header=" + headerJson + "&Content=" + contentJson;

               

               //send web request and store response

               var webRequest = (HttpWebRequest)WebRequest.Create(url);

               webRequest.ContentType = "application/json";

               webRequest.Method = "POST";

               var result = "";

               var httpResponse = (HttpWebResponse)webRequest.GetResponse();

               using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

               {

                   result = streamReader.ReadToEnd();

               }


               AccountDetailRootObject accountDetail = new AccountDetailRootObject();

               accountDetail = JsonConvert.DeserializeObject<AccountDetailRootObject>(result);


               string ErrorID = accountDetail.Content.ServiceResponse.ServiceRespHeader.GlobalErrorID?.ToString() ?? "-";


               if (ErrorID == "010000")

               {

                   lblTest.Text = accountDetail.Content.ServiceResponse.ServiceRespHeader.ErrorText.ToString();

                   lblAccountOpenDate.Text = accountDetail.Content.ServiceResponse.DepositAccount.AccountOpenDate?.ToString() ?? "-";

                   lblAssignedAccountForFeeDeduction.Text = accountDetail.Content.ServiceResponse.DepositAccount.AssignedAccountForAccountManagementFeeDeduction?.ToString() ?? "-";

                   lblBalance.Text = accountDetail.Content.ServiceResponse.DepositAccount.Balance?.ToString() ?? "-";

                   lblCurrency.Text = accountDetail.Content.ServiceResponse.DepositAccount.Currency?.ToString() ?? "-";

                   lblCurrentStatus.Text = accountDetail.Content.ServiceResponse.DepositAccount.CurrentStatus?.ToString() ?? "-";

                   lblCustomerID.Text = accountDetail.Content.ServiceResponse.DepositAccount.CustomerID?.ToString() ?? "-";

                   lblHomeBranch.Text = accountDetail.Content.ServiceResponse.DepositAccount.HomeBranch?.ToString() ?? "-";

                   lblInterestRate.Text = accountDetail.Content.ServiceResponse.DepositAccount.InterestRate?.ToString() ?? "-";

                   lblIsServiceChargeWaived.Text = accountDetail.Content.ServiceResponse.DepositAccount.IsServiceChargeWaived?.ToString() ?? "-";

                   lblMaturityDate.Text = accountDetail.Content.ServiceResponse.DepositAccount.MaturityDate?.ToString() ?? "-";

                   lblNarrative.Text = accountDetail.Content.ServiceResponse.DepositAccount.Narrative?.ToString() ?? "-";

                   lblOfficerID.Text = accountDetail.Content.ServiceResponse.DepositAccount.OfficerID?.ToString() ?? "-";

                   lblPenaltyRate.Text = accountDetail.Content.ServiceResponse.DepositAccount.PenaltyRate?.ToString() ?? "-";

                   lblCompoundInterestRateBasis.Text = accountDetail.Content.ServiceResponse.DepositAccount.Product.CompoundInterestRateBasis?.ToString() ?? "-";

                   lblDateBasisForRate.Text = accountDetail.Content.ServiceResponse.DepositAccount.Product.DateBasisForRate?.ToString() ?? "-";

                   lblProductID.Text = accountDetail.Content.ServiceResponse.DepositAccount.Product.ProductID?.ToString() ?? "-";

                   lblProductName.Text = accountDetail.Content.ServiceResponse.DepositAccount.Product.ProductName?.ToString() ?? "-";

                   lblRateChartCode.Text = accountDetail.Content.ServiceResponse.DepositAccount.Product.RateChartCode?.ToString() ?? "-";

                   lblAccountCloseDate.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.AccountCloseDate?.ToString() ?? "-";

                   lblAccurueInterestAmount.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.AccrueInterestAmount?.ToString() ?? "-";

                   lblDepositTerm.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.DepositTerm?.ToString() ?? "-";

                   lblDueInterestAmount.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.DueInterestAmount?.ToString() ?? "-";

                   lblInterestPayoutAccount.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.InterestPayoutAccount?.ToString() ?? "-";

                   lblIsRestricted.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.IsRestricted?.ToString() ?? "-";

                   lblMinimumAmount.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.MinimumAmount?.ToString() ?? "-";

                   lblMinorStatus.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.MinorStatus?.ToString() ?? "-";

                   lblParentAccountFlag.Text = accountDetail.Content.ServiceResponse.DepositAccount.Casaaccount.ParentAccountFlag?.ToString() ?? "-";

                   lblLastMaintenanceOfficer.Text = accountDetail.Content.ServiceResponse.DepositAccount.Maintenancehistory.LastMaintenanceOfficer?.ToString() ?? "-";

                   lblLastTransactionBranch.Text = accountDetail.Content.ServiceResponse.DepositAccount.Maintenancehistory.LastTransactionBranch?.ToString() ?? "-";

               }

               else if (ErrorID == "010041")

               {

                   otp = utilities.newOTP();

                   Session["otp"] = otp;

               }

               else

               {

                   lblTest.Text = accountDetail.Content.ServiceResponse.ServiceRespHeader.ErrorText.ToString();

                   string errorMessage = accountDetail.Content.ServiceResponse.ServiceRespHeader.ErrorDetails.ToString();

                   MessageBox.Show(errorMessage);

               }

           }


           catch(Exception ex)

           {

               lblExceptionMsg.Text = ex.ToString();

           }

       }

   }

}



Download





Created with the Personal Edition of HelpNDoc: Easily create CHM Help documents