public Account createNewBusinessAccount(string userNBR, string ctryCD, string langCD) { try { var newAcct = new Account(); var ctryCrcy = new CountryCurrency(); //get Account currency string crcyCD = ctryCrcy.getCurrencyByCountry(ctryCD); if (string.IsNullOrWhiteSpace(crcyCD)) { throw new Exception(); } //add the date and to avoid duplicate value of ACCT_NBR before updating int dtSecond = DateTime.Now.Second; int dtMillisecond = DateTime.Now.Millisecond; string acctNbr = string.Concat(ctryCD, "00000", dtSecond, dtMillisecond); //get Account Culture Info string acctCulInfo = ctryCrcy.getCultureInfoByCountryAndLanguage(ctryCD, langCD); if (string.IsNullOrWhiteSpace(acctCulInfo)) { throw new Exception(); } newAcct.ACCT_TCD = "2"; newAcct.CRCY_CD = crcyCD; newAcct.ACCT_SCD = "01"; newAcct.ACCT_NBR = acctNbr; newAcct.ACCT_NAME = "Compte Courant Affaire"; newAcct.ACCT_BAL = 0.0m; newAcct.ACCT_CLTR_INFO = acctCulInfo; newAcct.LGC_DEL_IND = "0"; newAcct.USR_NBR = userNBR; newAcct.ACCT_CDT = DateTime.Now; return(newAcct); } catch { return(null); } }
public Account createNewBusinessUserAccount(int bn, string busAgcyNbr, string userNBR, string ctryCD, string langCD) { try { var newAcct = new Account(); var ctryCrcy = new CountryCurrency(); //get Account currency string crcyCD = ctryCrcy.getCurrencyByCountry(ctryCD); if (string.IsNullOrWhiteSpace(crcyCD)) { throw new Exception(); } //generate client account number var busAgcyList = db.TBUS_AGCY.Where(x => x.BN == bn && x.BUS_AGCY_NBR == busAgcyNbr).ToList(); if (busAgcyList.Count() == 0) { return(null); } var busAgcy = busAgcyList[0]; //find agency account var busAcct = db.TACCT.Find(busAgcy.BUS_AGCY_ACCT_ID); if (busAcct == null) { return(null); } int currentLength = db.TBUS_USR.Where(x => x.BN == bn && x.BUS_AGCY_NBR == busAgcyNbr).Count(); if (busAgcyList.Count() == 0) { return(null); } string acctNbr = busAcct.ACCT_NBR + CommonLibrary.generateStringCode(3, currentLength); if (string.IsNullOrWhiteSpace(acctNbr) || acctNbr.Length != 20) { throw new Exception(); } //get Account Culture Info string acctCulInfo = ctryCrcy.getCultureInfoByCountryAndLanguage(ctryCD, langCD); if (string.IsNullOrWhiteSpace(acctCulInfo)) { throw new Exception(); } newAcct.ACCT_TCD = "2"; newAcct.CRCY_CD = crcyCD; newAcct.ACCT_SCD = "01"; newAcct.ACCT_NBR = acctNbr; newAcct.ACCT_NAME = "Compte Courant Affaire"; newAcct.ACCT_BAL = 0.0m; newAcct.ACCT_CLTR_INFO = acctCulInfo; newAcct.LGC_DEL_IND = "0"; newAcct.USR_NBR = userNBR; newAcct.ACCT_CDT = DateTime.Now; return(newAcct); } catch { return(null); } }
public Account createNewClientAccount(string usrNbr, string ctryCD, string crcyCD, string langCD, string clientTCD) { var newAcct = new Account(); var ctryCrcy = new CountryCurrency(); var newAcctIdent = new AccountIdentity(); try { var acctIdent = newAcctIdent.generateLastPartAccountNumber(); if ((clientTCD != "1" && clientTCD != "3") || acctIdent == null) { return(null); } //get param string acctNbr = null; string ACCT_TCD = null; string ACCT_NAME = null; string acctCrcyCD = null; string acctCulInfo = null; string lastPartAcctNbr = Convert.ToString(acctIdent.ACCT_ID); if (clientTCD == "1") { ACCT_TCD = "1"; //currentLength = db.TACCT.Where(x => x.ACCT_TCD == ACCT_TCD && x.ACCT_NBR.StartsWith(ctryCD)).ToList().Count(); acctNbr = ctryCD + "C" + lastPartAcctNbr; ACCT_NAME = "Compte Courant Particulier"; acctCrcyCD = ctryCrcy.getCurrencyByCountry(ctryCD); acctCulInfo = ctryCrcy.getCultureInfoByCountryAndLanguage(ctryCD, langCD); } if (clientTCD == "3") { ACCT_TCD = "3"; //currentLength = db.TACCT.Where(x => x.ACCT_TCD == ACCT_TCD && x.ACCT_NBR.StartsWith(ctryCD)).ToList().Count(); acctNbr = ctryCD + "X" + lastPartAcctNbr; ACCT_NAME = "Compte Carte Particulier"; acctCrcyCD = crcyCD; acctCulInfo = ctryCrcy.getCultureInfoByCurrencyCD(crcyCD, langCD); } if (string.IsNullOrWhiteSpace(acctNbr) || acctNbr.Length != 12 || string.IsNullOrWhiteSpace(acctCrcyCD) || string.IsNullOrWhiteSpace(acctCulInfo)) { throw new Exception(); } newAcct.ACCT_TCD = ACCT_TCD; newAcct.CRCY_CD = acctCrcyCD; newAcct.ACCT_SCD = "01"; newAcct.ACCT_NBR = acctNbr; newAcct.ACCT_NAME = ACCT_NAME; newAcct.ACCT_BAL = 0.0m; newAcct.ACCT_CLTR_INFO = acctCulInfo; newAcct.LGC_DEL_IND = "0"; newAcct.USR_NBR = usrNbr; newAcct.ACCT_CDT = DateTime.Now; return(newAcct); } catch { return(null); } }