public int Close_Auth(string accountId) { SetError(0, String.Empty); Account_Info acInfo = dalAc.GetOneAccount(accountId); if (acInfo == null) { SetError(11, "Account not find"); return(Error_Number); } if (acInfo.Approved == false) { SetError(13, "Account not approved"); return(Error_Number); } if (acInfo.Closed == true) { SetError(21, "Account closed"); return(Error_Number); } if (acInfo.Locked == true) { SetError(22, "Account locked"); return(Error_Number); } if (acInfo.Balance != 0) { SetError(19, "Account not allow closed still balance"); return(Error_Number); } return(Error_Number); }
/// <summary> /// Get one Account detail /// </summary> /// <param name="accountId"></param> /// <returns>Account_Info</returns> public new xml_response GetAccountById(string accountId) { try { _res = new xml_response(); _res.function_name = this.ToString() + string.Format(".GetAccountById({0})", accountId); if (logger.IsDebugEnabled) { logger.Debug(string.Format("Start function: {0}", _res.function_name)); } Account_Info ai = base.GetAccountById(accountId); if (ai == null) { // không tìm thấy thông tin tài khoản. _res.SetError("11", string.Format("Account: {0} not found", accountId)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } } else { _res.Accounts = ai.RenderXML(); } } catch (Exception ex) { if (logger.IsErrorEnabled) { logger.Error(ex); } throw; } return(_res); }
public Edit(Account account) { InitializeComponent(); this.account = account; cbType.FlatStyle = FlatStyle.Flat; cbType.DataSource = Account_TypeController.getController().getTypeTable(); cbType.DisplayMember = "Name"; cbType.ValueMember = "ID"; var info = Account_InfoController.getController().findOneWithType(account.Username); if (info != null) { account_Info = info.Item1; account_Type = info.Item2; tbFirstName.Text = account_Info.First_Name; tbLastName.Text = account_Info.Last_Name; tbPhone.Text = account_Info.Phone; rtbAddress.Text = account_Info.Address; rtbNote.Text = account_Info.Note; dtpBd.Value = account_Info.Birthday; } else { tbFirstName.Text = ""; tbLastName.Text = ""; tbPhone.Text = ""; rtbAddress.Text = ""; rtbNote.Text = ""; } tbDisplay.Text = account.Display_Name; cbType.SelectedValue = account.Type; }
private void button1_Click(object sender, EventArgs e) { bool flag1 = false, flag2 = false; //Update DisplayName if (tbDisplay.Text != account.Display_Name || (int)cbType.SelectedValue != account.Type ) { account.Display_Name = tbDisplay.Text; account.Type = (int)cbType.SelectedValue; if (!AccountController.getController().update(account)) { MessageBox.Show("không thể update tên hiển thị"); } else { flag1 = true; } } else { flag1 = true; } if (account_Info == null) { account_Info = new Account_Info(); } if (tbFirstName.Text != account_Info.First_Name || tbLastName.Text != account_Info.Last_Name || tbPhone.Text != account_Info.Phone || rtbAddress.Text != account_Info.Address || rtbNote.Text != account_Info.Note || dtpBd.Value != account_Info.Birthday) { account_Info.First_Name = tbFirstName.Text; account_Info.Last_Name = tbLastName.Text; account_Info.Phone = tbPhone.Text; account_Info.Note = rtbNote.Text; account_Info.Address = rtbAddress.Text; account_Info.Birthday = dtpBd.Value; if (!Account_InfoController.getController().Update(account_Info)) { MessageBox.Show("không thể update thông tin"); } else { flag2 = true; } } else { flag2 = true; } if (flag1 && flag2) { MessageBox.Show("Thành công"); this.Close(); } }
public int UnBlock_Auth(string accountId, decimal amount) { SetError(0, String.Empty); Account_Info acInfo = dalAc.GetOneAccount(accountId); if (acInfo == null) { SetError(11, "Account not find"); return(Error_Number); } if (acInfo.Approved == false) { SetError(13, "Account not approved"); return(Error_Number); } if (acInfo.Closed == true) { SetError(21, "Account closed"); return(Error_Number); } if (acInfo.Locked == true) { SetError(22, "Account locked"); return(Error_Number); } if (Math.Abs(acInfo.Amount_Blocked) < amount) { SetError(24, "Amount blocked is not enough"); return(Error_Number); } return(Error_Number); }
public int Insert_Auth(Account_Info obj) { SetError(0, String.Empty); if (string.IsNullOrEmpty(obj.Account_ID)) { SetError(98, "Invalid Account ID"); return(Error_Number); } if (string.IsNullOrEmpty(obj.Name)) { SetError(98, "Invalid Account Name"); return(Error_Number); } Branches dalBranch = new Branches(); if (dalBranch.GetBranchesByID(obj.Branch_ID) == null) { SetError(70, "Branch Id not find"); return(Error_Number); } Categories dalCat = new Categories(); Categories_Info catInfo = dalCat.GetCategoriesByID(obj.Categories); if (catInfo == null) { SetError(71, "Categories Id not find"); return(Error_Number); } Customer dalCust = new Customer(); Customer_Info custInfo = dalCust.GetCustomerByID(obj.Customer_ID); if (custInfo == null) { SetError(1, "Customer not find"); return(Error_Number); } if (!custInfo.Active) { SetError(3, "Customer has been not active"); return(Error_Number); } Account_Info acInfo = base.GetAccountBy(obj.Branch_ID, obj.Categories, obj.Customer_ID); if (acInfo != null) { SetError(12, "Account opened"); return(Error_Number); } acInfo = base.GetAccountById(obj.Account_ID); if (acInfo != null) { SetError(12, "Account opened"); return(Error_Number); } return(Error_Number); }
public async Task <IActionResult> ProfileApplication(Investment_Info invest, Account_Info account) { if (ModelState.IsValid) { //Get the existing user from the database var user = await _userManager.GetUserAsync(User); //check if user already filled out the investment Questions var entity = _context.UserInvestment.FirstOrDefault(i => i.UserID == user.Id); if (entity != null) { //update user investment question //convert Ques1 & Ques2 to all Capital Letter invest.Ques1 = invest.Ques1.ToUpper(); invest.Ques2 = invest.Ques2.ToUpper(); //Append User signature to User Record user.Signature = invest.Signature; user.FirstAccessed = false; await _userManager.UpdateAsync(user); _logger.LogInformation("User signature appended updated"); //Append UserID to User's investment Record entity.FormType = "User Profile"; _context.UserInvestment.Update(entity); _context.SaveChanges(); _logger.LogInformation("User investment info Updated"); } else { //convert Ques1 & Ques2 to all Capital Letter invest.Ques1.ToUpper(); invest.Ques2.ToUpper(); //Append User signature to User Record user.Signature = invest.Signature; user.FirstAccessed = false; await _userManager.UpdateAsync(user); _logger.LogInformation("User signature appended and firstAccessed value updated"); //Append UserID to User's investment Record invest.UserID = user.Id; invest.FormType = "User Profile"; _context.UserInvestment.Add(invest); _logger.LogInformation("User beneficiary and investment background added."); } return(RedirectToAction("Index", "Account")); } return(View()); }
/// <summary> /// Sửa thông tin tài khoản /// </summary> /// <param name="accountInfo">Thông tin tài khoản chi tiết</param> /// <returns>#0 nếu thành công</returns> protected int Update(Account_Info accountInfo) { dalAc.EditOneAccount(accountInfo); if (dalAc.Execute()) { return(dalAc.LastRecordsEffected); } throw dalAc.GetException; }
/// <summary> /// hàm bỏ khóa số dư tài khoản /// </summary> /// <param name="accountId"></param> /// <param name="amnt"></param> /// <returns></returns> public new xml_response UnBlock(string accountId, decimal amnt) { try { _res = new xml_response(); _res.function_name = this.ToString() + string.Format(".UnBlock({0}, {1})", accountId, amnt); if (logger.IsDebugEnabled) { logger.Debug(string.Format("Start function: {0}", _res.function_name)); } //D_Account da = new D_Account(); Account da = new Account(); Account_Info ai = da.GetAccountByID(accountId); if (ai == null) { _res.SetError("11", string.Format("Account {0} can not find", accountId)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } if (ai.BalanceAvaiable < amnt) { _res.SetError("14", "Account balance is not enough"); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } // Thực hiện bỏ khóa số dư if (base.UnBlock(ai, amnt) == 0) { // mở khóa số dư không thành công _res.SetError("99", base.Error_Message); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } } } catch (Exception ex) { if (logger.IsErrorEnabled) { logger.Error(ex); } throw; } return(_res); }
/// <summary> /// Hàm thực hiện tạm khóa không cho sử dụng tài khoản /// </summary> /// <param name="acInfo">Thông tin tài khoản chi tiết</param> /// <returns></returns> protected int Lock(Account_Info acInfo) { if (acInfo == null) { throw new Exception("acInfo is null or empty"); } acInfo.Locked = true; acInfo.Last_Date = DateTime.Now; dalAc.EditOneAccount(acInfo); if (dalAc.Execute()) { return(dalAc.LastRecordsEffected); } throw dalAc.GetException; }
/// <summary> /// Hàm bỏ khóa số dư tài khoản. /// </summary> /// <param name="acInfo">Mã tài khoản chi tiết</param> /// <param name="amnt">Số tiền cần bỏ khóa</param> /// <returns>=0 nếu thành công và #0 nếu gặp lỗi</returns> protected int UnBlock(Account_Info acInfo, decimal amnt) { if (acInfo == null) { throw new Exception("acInfo is null or empty"); } acInfo.Amount_Blocked -= amnt; acInfo.Last_Date = DateTime.Now; dalAc.EditOneAccount(acInfo); if (dalAc.Execute()) { return(dalAc.LastRecordsEffected); } throw dalAc.GetException; }
public void CreateOneAccount(Account_Info objAccountInfo) { try { dynamic acc_info = new ePayment.DataProvider.DynamicObj(); acc_info.Account_ID = objAccountInfo.Account_ID; ePayment.DataProvider.MongoHelper.Save("Account", acc_info); } catch (Exception ex) { //ePayment.DataProvider.MongoHelper. //Logger.Error(ex); throw ex; } }
/// <summary> /// truy vấn số dư tài khoản tại thời điểm hiện tại /// </summary> /// <param name="account_id">mã số tài khoản</param> /// <returns>số dư tài khoản (không bao gồm số dư bị block)</returns> public ResponseMessage BalanceInquiry(string pan) { ResponseMessage msg = new ResponseMessage(); msg.LocalDate = DateTime.Now.ToString("MMdd"); msg.LocalTime = DateTime.Now.ToString("hhmmss"); Account_Info ai = base.Balance(pan); if (ai == null) { logger.Error(string.Format("Account ID: {0} does not found", pan)); msg.ResponseCode = "14"; // Invalid card number return(msg); } msg.BalanceParse(ai.Balance); return(msg); }
public int UnLock_Auth(string accountId) { SetError(0, String.Empty); Account_Info acInfo = dalAc.GetOneAccount(accountId); if (acInfo == null) { SetError(11, "Account not find"); return(Error_Number); } if (acInfo.Locked == false) { SetError(23, "Account not lock"); return(Error_Number); } return(Error_Number); }
public int Delete_Auth(string accountId) { SetError(0, String.Empty); Account_Info acInfo = dalAc.GetOneAccount(accountId); if (acInfo == null) { SetError(11, "Account not find"); return(Error_Number); } if (acInfo.Approved == true) { SetError(20, "Account approved"); return(Error_Number); } return(Error_Number); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Tài khoản và mật khẩu không được bỏ trống!"); } else if (tbDisplayName.Text == "") { MessageBox.Show("Tên hiển thị không được để trống!"); } else { Account account = new Account(); account.Display_Name = tbDisplayName.Text; account.Username = textBox1.Text; // Thêm kiểm tra tên account.Password = textBox2.Text.makeMD5(); // Thêm kiểm tra mật khẩu account.Type = (int)cbType.SelectedValue; if (AccountController.getController().exits(account)) { MessageBox.Show("Tên tài khoản đã tồn tại!"); } else { Account_Info info = new Account_Info(); info.First_Name = tbFirstName.Text.Trim() == "" ? "None" : tbFirstName.Text.Trim(); info.Last_Name = tbLastName.Text.Trim() == "" ? "None" : tbLastName.Text.Trim(); info.Birthday = dtpBirthDay.Value; account.Info = Account_InfoController.getController().SaveNew(info); bool done = AccountController.getController().createAccount(account); if (done) { MessageBox.Show("Tạo thành công tài khoản: " + account.Username); this.Close(); } else { MessageBox.Show("Đã xảy ra lỗi "); } } } }
public new int Update(Account_Info obj) { int result = Update_Auth(obj); if (result != 0) { return(result); } obj.Last_Date = DateTime.Now; if (base.Update(obj) != 0) { SetError(0, String.Empty); } else { SetError(99, dalAc.GetException.Message); } return(Error_Number); }
public int Block(string accountId, decimal amount) { int result = Block_Auth(accountId, amount); if (result != 0) { return(result); } Account_Info acInfo = dalAc.GetOneAccount(accountId); if (base.Block(acInfo, amount) != 0) { SetError(0, String.Empty); } else { SetError(99, dalAc.GetException.Message); } return(Error_Number); }
public int Close(string accountId) { int result = Close_Auth(accountId); if (result != 0) { return(result); } Account_Info acInfo = dalAc.GetOneAccount(accountId); if (base.Close(acInfo) != 0) { SetError(0, String.Empty); } else { SetError(99, dalAc.GetException.Message); } return(Error_Number); }
public int Approved(string accountId) { int result = Approved_Auth(accountId); if (result != 0) { return(result); } Account_Info acInfo = dalAc.GetOneAccount(accountId); acInfo.Approved = true; acInfo.Last_Date = DateTime.Now; dalAc.EditOneAccount(acInfo); if (dalAc.Execute()) { SetError(0, String.Empty); } else { SetError(99, dalAc.GetException.Message); } return(Error_Number); }
public int Update_Auth(Account_Info obj) { SetError(0, String.Empty); if (obj == null) { SetError(98, "Object is null"); return(Error_Number); } if (string.IsNullOrEmpty(obj.Name)) { SetError(11, "Account name is null or empty"); return(Error_Number); } Account_Info acInfo = base.GetAccountById(obj.Account_ID); if (acInfo == null) { SetError(11, "Account not find"); return(Error_Number); } if (acInfo.Approved == true) { SetError(20, "Account approved"); return(Error_Number); } if (acInfo.Closed == true) { SetError(21, "Account closed"); return(Error_Number); } if (acInfo.Locked == true) { SetError(22, "Account locked"); return(Error_Number); } return(Error_Number); }
/// <summary> /// gán đối đượng Account_info /// </summary> /// <param name="row"></param> /// <returns>thông tin tài khoản chi tiết</returns> private static Account_Info GenerateObject(DataRow row) { if (row == null) { throw new Exception("Data row does not null or empty"); } Account_Info objAccountInfo = new Account_Info(); if (row["Account_ID"] != DBNull.Value) { objAccountInfo.Account_ID = Convert.ToString(row["Account_ID"]); } if (row["Name"] != DBNull.Value) { objAccountInfo.Name = Convert.ToString(row["Name"]); } if (row["Ref"] != DBNull.Value) { objAccountInfo.Reference = Convert.ToString(row["Ref"]); } if (row["b_Credit"] != DBNull.Value) { objAccountInfo.b_Credit = Convert.ToDecimal(row["b_Credit"]); } if (row["y_Credit"] != DBNull.Value) { objAccountInfo.y_Credit = Convert.ToDecimal(row["y_Credit"]); } if (row["y_Debit"] != DBNull.Value) { objAccountInfo.y_Debit = Convert.ToDecimal(row["y_Debit"]); } if (row["q_Credit"] != DBNull.Value) { objAccountInfo.q_Credit = Convert.ToDecimal(row["q_Credit"]); } if (row["q_Debit"] != DBNull.Value) { objAccountInfo.q_Debit = Convert.ToDecimal(row["q_Debit"]); } if (row["m_Credit"] != DBNull.Value) { objAccountInfo.m_Credit = Convert.ToDecimal(row["m_Credit"]); } if (row["m_Debit"] != DBNull.Value) { objAccountInfo.m_Debit = Convert.ToDecimal(row["m_Debit"]); } if (row["w_Credit"] != DBNull.Value) { objAccountInfo.w_Credit = Convert.ToDecimal(row["w_Credit"]); } if (row["w_Debit"] != DBNull.Value) { objAccountInfo.w_Debit = Convert.ToDecimal(row["w_Debit"]); } if (row["d_Credit"] != DBNull.Value) { objAccountInfo.d_Credit = Convert.ToDecimal(row["d_Credit"]); } if (row["d_Debit"] != DBNull.Value) { objAccountInfo.d_Debit = Convert.ToDecimal(row["d_Debit"]); } if (row["CreditDebit"] != DBNull.Value) { objAccountInfo.CreditDebit = (AccountType)Enum.Parse(typeof(AccountType), row["CreditDebit"].ToString()); } if (row["Ccy"] != DBNull.Value) { objAccountInfo.Ccy = Convert.ToString(row["Ccy"]); } if (row["Account_GL"] != DBNull.Value) { objAccountInfo.Account_GL = Convert.ToString(row["Account_GL"]); } if (row["Branch_ID"] != DBNull.Value) { objAccountInfo.Branch_ID = Convert.ToString(row["Branch_ID"]); } if (row["Customer_ID"] != DBNull.Value) { objAccountInfo.Customer_ID = Convert.ToString(row["Customer_ID"]); } if (row["Categories"] != DBNull.Value) { objAccountInfo.Categories = Convert.ToString(row["Categories"]); } if (row["Amount_Blocked"] != DBNull.Value) { objAccountInfo.Amount_Blocked = Convert.ToDecimal(row["Amount_Blocked"]); } if (row["ApprovedTime"] != DBNull.Value) { objAccountInfo.ApprovedTime = Convert.ToDateTime(row["ApprovedTime"]); } if (row["Approved"] != DBNull.Value) { objAccountInfo.Approved = Convert.ToBoolean(row["Approved"]); } if (row["Locked"] != DBNull.Value) { objAccountInfo.Locked = Convert.ToBoolean(row["Locked"]); } if (row["UNC_Rpt"] != DBNull.Value) { objAccountInfo.UNC_Rpt = Convert.ToString(row["UNC_Rpt"]); } if (row["Closed"] != DBNull.Value) { objAccountInfo.Closed = Convert.ToBoolean(row["Closed"]); } if (row["Closed_date"] != DBNull.Value) { objAccountInfo.Closed_date = Convert.ToDateTime(row["Closed_date"]); } if (row["Open_Date"] != DBNull.Value) { objAccountInfo.Open_Date = Convert.ToDateTime(row["Open_Date"]); } if (row["Last_Date"] != DBNull.Value) { objAccountInfo.Last_Date = Convert.ToDateTime(row["Last_Date"]); } if (row["UserCreate"] != DBNull.Value) { objAccountInfo.UserCreate = Convert.ToString(row["UserCreate"]); } if (row["IS_CHECKSUM"] != DBNull.Value) { objAccountInfo.CheckSumValue = Convert.ToString(row["IS_CHECKSUM"]); } return(objAccountInfo); }
/// <summary> /// tạo tài khoản mới /// </summary> /// <param name="objAccountInfo"></param> /// <returns></returns> public SqlCommand CreateOneAccount(Account_Info objAccountInfo) { try { SqlCommand command = new SqlCommand( "INSERT INTO Account(" + "Account_ID, " + "Name, " + "Ref, " + "b_Credit, " + "y_Credit, " + "y_Debit, " + "q_Credit, " + "q_Debit, " + "m_Credit, " + "m_Debit, " + "w_Credit, " + "w_Debit, " + "d_Credit, " + "d_Debit, " + "CreditDebit, " + "Ccy, " + "Amount_Blocked, " + "Account_GL, " + "Branch_ID, " + "Customer_ID, " + "Categories, " + "ApprovedTime, " + "Approved, " + "Locked, " + "UNC_Rpt, " + "Open_Date, " + "Last_Date, " + "UserCreate " + ")" + "VALUES (" + "@Account_ID, " + "@Name, " + "@Ref, " + "@b_Credit, " + "@y_Credit, " + "@y_Debit, " + "@q_Credit, " + "@q_Debit, " + "@m_Credit, " + "@m_Debit, " + "@w_Credit, " + "@w_Debit, " + "@d_Credit, " + "@d_Debit, " + "@CreditDebit, " + "@Ccy, " + "@Amount_Blocked, " + "@Account_GL, " + "@Branch_ID, " + "@Customer_ID, " + "@Categories, " + "@ApprovedTime, " + "@Approved, " + "@Locked, " + "@UNC_Rpt, " + "@Open_Date, " + "@Last_Date, " + "@UserCreate " + ")"); command.CommandType = CommandType.Text; command.Parameters.Add("@Account_ID", SqlDbType.NVarChar, 25).Value = objAccountInfo.Account_ID; command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objAccountInfo.Name; if (!string.IsNullOrEmpty(objAccountInfo.Reference)) { command.Parameters.Add("@Ref", SqlDbType.NVarChar, 25).Value = objAccountInfo.Reference; } else { command.Parameters.Add("@Ref", SqlDbType.NVarChar, 25).Value = DBNull.Value; } command.Parameters.Add("@b_Credit", SqlDbType.Decimal).Value = objAccountInfo.b_Credit; command.Parameters.Add("@y_Credit", SqlDbType.Decimal).Value = objAccountInfo.y_Credit; command.Parameters.Add("@y_Debit", SqlDbType.Decimal).Value = objAccountInfo.y_Debit; command.Parameters.Add("@q_Credit", SqlDbType.Decimal).Value = objAccountInfo.q_Credit; command.Parameters.Add("@q_Debit", SqlDbType.Decimal).Value = objAccountInfo.q_Debit; command.Parameters.Add("@m_Credit", SqlDbType.Decimal).Value = objAccountInfo.m_Credit; command.Parameters.Add("@m_Debit", SqlDbType.Decimal).Value = objAccountInfo.m_Debit; command.Parameters.Add("@w_Credit", SqlDbType.Decimal).Value = objAccountInfo.w_Credit; command.Parameters.Add("@w_Debit", SqlDbType.Decimal).Value = objAccountInfo.w_Debit; command.Parameters.Add("@d_Credit", SqlDbType.Decimal).Value = objAccountInfo.d_Credit; command.Parameters.Add("@d_Debit", SqlDbType.Decimal).Value = objAccountInfo.d_Debit; command.Parameters.Add("@CreditDebit", SqlDbType.NVarChar, 10).Value = objAccountInfo.CreditDebit; command.Parameters.Add("@Ccy", SqlDbType.NVarChar, 25).Value = objAccountInfo.Ccy; command.Parameters.Add("@Account_GL", SqlDbType.NVarChar, 25).Value = objAccountInfo.Account_GL; command.Parameters.Add("@Branch_ID", SqlDbType.NVarChar, 25).Value = objAccountInfo.Branch_ID; command.Parameters.Add("@Customer_ID", SqlDbType.NVarChar, 25).Value = objAccountInfo.Customer_ID; command.Parameters.Add("@Categories", SqlDbType.NVarChar, 25).Value = objAccountInfo.Categories; command.Parameters.Add("@Amount_Blocked", SqlDbType.Decimal).Value = objAccountInfo.Amount_Blocked; if (objAccountInfo.ApprovedTime != new DateTime(0)) { command.Parameters.Add("@ApprovedTime", SqlDbType.DateTime).Value = objAccountInfo.ApprovedTime; } else { command.Parameters.Add("@ApprovedTime", SqlDbType.DateTime).Value = DBNull.Value; } command.Parameters.Add("@Approved", SqlDbType.Bit).Value = objAccountInfo.Approved; command.Parameters.Add("@Locked", SqlDbType.Bit).Value = objAccountInfo.Locked; if (objAccountInfo.UNC_Rpt != null) { command.Parameters.Add("@UNC_Rpt", SqlDbType.NVarChar, 50).Value = objAccountInfo.UNC_Rpt; } else { command.Parameters.Add("@UNC_Rpt", SqlDbType.NVarChar, 50).Value = DBNull.Value; } command.Parameters.Add("@Open_Date", SqlDbType.DateTime).Value = DateTime.Now; command.Parameters.Add("@Last_Date", SqlDbType.DateTime).Value = DateTime.Now; command.Parameters.Add("@UserCreate", SqlDbType.NVarChar, 25).Value = objAccountInfo.UserCreate; this.AddCommand(command); return(command); } catch (Exception ex) { Logger.Error(ex); throw ex; } }
/// <summary> /// Hàm cập nhật thông tin tài khoản /// </summary> /// <param name="objAccountInfo">thông tin tài khoản chi tiết</param> /// <param name="forceUpdate">= true cập nhật không cần checksume /// =false kiểm tra điều kiện toàn vẹn dữ liệu checksume</param> /// <returns>SqlCommand</returns> public SqlCommand EditOneAccount(Account_Info objAccountInfo, bool forceUpdate) { try { SqlCommand command = new SqlCommand("AccountUpdate"); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@Account_ID", SqlDbType.NVarChar, 25).Value = objAccountInfo.Account_ID; command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objAccountInfo.Name; if (!string.IsNullOrEmpty(objAccountInfo.Reference)) { command.Parameters.Add("@Ref", SqlDbType.NVarChar, 25).Value = objAccountInfo.Reference; } else { command.Parameters.Add("@Ref", SqlDbType.NVarChar, 25).Value = DBNull.Value; } command.Parameters.Add("@b_Credit", SqlDbType.Decimal).Value = objAccountInfo.b_Credit; command.Parameters.Add("@y_Credit", SqlDbType.Decimal).Value = objAccountInfo.y_Credit; command.Parameters.Add("@y_Debit", SqlDbType.Decimal).Value = objAccountInfo.y_Debit; command.Parameters.Add("@q_Credit", SqlDbType.Decimal).Value = objAccountInfo.q_Credit; command.Parameters.Add("@q_Debit", SqlDbType.Decimal).Value = objAccountInfo.q_Debit; command.Parameters.Add("@m_Credit", SqlDbType.Decimal).Value = objAccountInfo.m_Credit; command.Parameters.Add("@m_Debit", SqlDbType.Decimal).Value = objAccountInfo.m_Debit; command.Parameters.Add("@w_Credit", SqlDbType.Decimal).Value = objAccountInfo.w_Credit; command.Parameters.Add("@w_Debit", SqlDbType.Decimal).Value = objAccountInfo.w_Debit; command.Parameters.Add("@d_Credit", SqlDbType.Decimal).Value = objAccountInfo.d_Credit; command.Parameters.Add("@d_Debit", SqlDbType.Decimal).Value = objAccountInfo.d_Debit; command.Parameters.Add("@CreditDebit", SqlDbType.NVarChar, 10).Value = objAccountInfo.CreditDebit; command.Parameters.Add("@Ccy", SqlDbType.NVarChar, 3).Value = objAccountInfo.Ccy; command.Parameters.Add("@Account_GL", SqlDbType.NVarChar, 25).Value = objAccountInfo.Account_GL; command.Parameters.Add("@Branch_ID", SqlDbType.NVarChar, 25).Value = objAccountInfo.Branch_ID; command.Parameters.Add("@Customer_ID", SqlDbType.NVarChar, 25).Value = objAccountInfo.Customer_ID; command.Parameters.Add("@Categories", SqlDbType.NVarChar, 25).Value = objAccountInfo.Categories; command.Parameters.Add("@Amount_Blocked", SqlDbType.Decimal).Value = objAccountInfo.Amount_Blocked; if (objAccountInfo.ApprovedTime != new DateTime(0)) { command.Parameters.Add("@ApprovedTime", SqlDbType.DateTime).Value = objAccountInfo.ApprovedTime; } else { command.Parameters.Add("@ApprovedTime", SqlDbType.DateTime).Value = DBNull.Value; } command.Parameters.Add("@Approved", SqlDbType.Bit).Value = objAccountInfo.Approved; command.Parameters.Add("@Locked", SqlDbType.Bit).Value = objAccountInfo.Locked; if (objAccountInfo.UNC_Rpt != null) { command.Parameters.Add("@UNC_Rpt", SqlDbType.NVarChar, 50).Value = objAccountInfo.UNC_Rpt; } else { command.Parameters.Add("@UNC_Rpt", SqlDbType.NVarChar, 50).Value = DBNull.Value; } if (objAccountInfo.Closed == true) { command.Parameters.Add("@Closed", SqlDbType.Bit).Value = objAccountInfo.Closed; command.Parameters.Add("@Closed_date", SqlDbType.DateTime).Value = objAccountInfo.Closed_date; } else { command.Parameters.Add("@Closed", SqlDbType.Bit).Value = objAccountInfo.Closed; command.Parameters.Add("@Closed_date", SqlDbType.DateTime).Value = DBNull.Value; } command.Parameters.Add("@Open_Date", SqlDbType.DateTime).Value = objAccountInfo.Open_Date; command.Parameters.Add("@Last_Date", SqlDbType.DateTime).Value = DateTime.Now; command.Parameters.Add("@UserCreate", SqlDbType.NVarChar, 25).Value = objAccountInfo.UserCreate; command.Parameters.Add("@CheckSumValue", SqlDbType.NVarChar, 4000).Value = objAccountInfo.CheckSumValue; command.Parameters.Add("@force_update", SqlDbType.Bit).Value = forceUpdate; this.AddCommand(command); return(command); } catch (Exception ex) { Logger.Error(ex); throw ex; } }
/// <summary> /// sửa đổi thông tin tài khoản /// </summary> /// <param name="objAccountInfo"></param> /// <returns></returns> public SqlCommand EditOneAccount(Account_Info objAccountInfo) { return(EditOneAccount(objAccountInfo, false)); }
/// <summary> /// Hàm kiểm tra điều kiện các luật số dư hay doanh số hạch toán, /// các luật này được định nghĩa chi tiết /// cho từng nhóm tài khoản trong bảng Account_Rules /// </summary> /// <param name="acc">thông tin tài khoản chi tiết cần kiểm tra luật</param> /// <param name="crdb">chuỗi ký tự quy định tài khoản sẽ được ghi nợ hay ghi có /// nếu chuỗi là "CR" là ghi có, còn nếu chuỗi là "DB" thì là ghi nợ</param> /// <param name="amnt">số dư hạch toán nợ hay có cần kiểm tra luật, /// điều kiện kiểm tra bao gồm cả số dư hiện tại của tài khoản và số dư hạch toán này</param> /// <returns>nếu không phạm luật thì hàm trả về giá trị true, /// còn nếu lỗi là false và chuỗi ký tự báo phạm luật gì qua biến _msgRule của lớp thư viện</returns> private bool CheckAccountRules(Account_Info acc, CreditDebit crdb, decimal amnt) { bool rule = true; // Kiểm tra số dư theo tính chất tài khoản. // ======== hạch toán nợ ========= if (crdb == CreditDebit.DB) { if (acc.CreditDebit == AccountType.DB) { // tài khoản mang tính chất nợ if (acc.b_Credit + acc.y_Credit - (acc.y_Debit + amnt) > 0) { _msgRule = string.Format("The {0} balance not enough ", acc.Account_ID); return(false); } } else if (acc.CreditDebit == AccountType.CR) { // tài khoản mang tính chất có if (acc.b_Credit + acc.y_Credit - (acc.y_Debit + amnt) < 0) { _msgRule = string.Format("The {0} balance not enough", acc.Account_ID); return(false); } } else { // tài khoản mang tính chất lưỡng tính luôn đúng rule = true; } } // ======== hạch toán có ========= if (crdb == CreditDebit.CR) { if (acc.CreditDebit == AccountType.DB) { // tài khoản mang tính chất nợ if (acc.b_Credit + (acc.y_Credit + amnt) - acc.y_Debit > 0) { _msgRule = string.Format("The {0} balance not enough ", acc.Account_ID); return(false); } } else if (acc.CreditDebit == AccountType.CR) { // tài khoản mang tính chất có if (acc.b_Credit + (acc.y_Credit + amnt) - acc.y_Debit < 0) { _msgRule = string.Format("The {0} balance not enough", acc.Account_ID); return(false); } } else { // tài khoản mang tính chất lưỡng tính luôn đúng rule = true; } } // ====================================== // kiểm tra điều kiện hạch toán theo luật // ====================================== var dar = new D_AccountRoles(); List <AccountRoles_Info> list = dar.GetSomething(acc.Account_ID); if (list == null) // nếu không có rule thì hoàn thành check { return(true); } foreach (AccountRoles_Info acR in list) { switch (acR.Type) { case AccountRoleType.CreditPerDay: if (crdb == CreditDebit.CR) { rule = OperationCompare(acc.d_Credit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.DebitPerDay: if (crdb == CreditDebit.DB) { rule = OperationCompare(acc.d_Debit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.CreditPerWeek: if (crdb == CreditDebit.CR) { rule = OperationCompare(acc.w_Credit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.DebitPerWeek: if (crdb == CreditDebit.DB) { rule = OperationCompare(acc.w_Debit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.CreditPerMonth: if (crdb == CreditDebit.CR) { rule = OperationCompare(acc.m_Credit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.DebitPerMonth: if (crdb == CreditDebit.DB) { rule = OperationCompare(acc.m_Debit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.CreditPerQuarter: if (crdb == CreditDebit.CR) { rule = OperationCompare(acc.q_Credit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.DebitPerQuarter: if (crdb == CreditDebit.DB) { rule = OperationCompare(acc.q_Debit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.CreditPerYear: if (crdb == CreditDebit.CR) { rule = OperationCompare(acc.y_Credit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.DebitPerYear: if (crdb == CreditDebit.DB) { rule = OperationCompare(acc.y_Debit + amnt, acR.Operator, acR.Value); } break; case AccountRoleType.CreditPerDeal: if (crdb == CreditDebit.CR) { rule = OperationCompare(amnt, acR.Operator, acR.Value); } break; case AccountRoleType.DebitPerDeal: if (crdb == CreditDebit.DB) { rule = OperationCompare(amnt, acR.Operator, acR.Value); } break; case AccountRoleType.OnBalance: decimal trial_bal = 0; // nếu là hạch toán nợ if (crdb == CreditDebit.DB) { trial_bal = acc.b_Credit + acc.y_Credit - (acc.y_Debit + amnt); } // nếu là hạch toán có if (crdb == CreditDebit.CR) { trial_bal = acc.b_Credit + (acc.y_Credit + amnt) - acc.y_Debit; } // đổi dấu nếu tài khoản mang tính chất nợ if (acc.CreditDebit == AccountType.DB) { trial_bal *= -1; } // so sánh theo số dư mới rule = OperationCompare(trial_bal, acR.Operator, acR.Value); break; } if (rule == false) { _msgRule = string.Format("Rule name:({0}){1}\t{2}\t{3}\t{4}", acR.ID, acR.Name, acR.Type, acR.Operator, acR.Value); break; } else { _msgRule = ""; } } return(rule); }
public xml_response Fundtransfer(string trancode, string fromAccount, string toAccount, decimal amount, string descript) { try { _res = new xml_response(); _res.function_name = this.ToString() + string.Format(".Fundtransfer({0}, {1}, {2}, {3},{4})", trancode, fromAccount, toAccount, amount, descript); if (logger.IsDebugEnabled) { logger.Debug(string.Format("Start function: {0}", _res.function_name)); } // kiểm tra trancode Trancode_Info trancodeInfo = _dalTrancode.GetOneTranCode(trancode); if (trancodeInfo == null) { _res.SetError("99", string.Format("Trancode Id: {0} not found", trancode)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } if (trancodeInfo.CodeType != CodeType.FundTransfer) { _res.SetError("99", string.Format("Trancode Id: {0} invalid code type", trancode)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } // kiểm tra tài khoản đã có hay chưa string db_account = fromAccount; string cr_account = toAccount; if (_dalAc.GetOneAccount(db_account) == null) { _res.SetError("11", string.Format("From account {0} does not found", db_account)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } if (_dalAc.GetOneAccount(cr_account) == null) { _res.SetError("11", string.Format("From account {0} does not found", cr_account)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } // kiểm tra số dư chuyển khoản. Tranday_Info trandayInfo = new Tranday_Info(); trandayInfo.AllowReverse = trancodeInfo.AllowReverse; trandayInfo.Branch_ID = _channel.Branch; if (string.IsNullOrEmpty(descript)) { trandayInfo.Descript = string.Format("transfer from {0} to {1} with amount = {2}", db_account, cr_account, amount); } else { trandayInfo.Descript = descript; } trandayInfo.NextDocId = ""; trandayInfo.Status = TransactionStatus.Approved; _transdate = BaseParameters.ToDay().TransDate; trandayInfo.TranCode = trancode; trandayInfo.TransDate = _transdate; trandayInfo.UserCreate = _channel.UserLogin; trandayInfo.ValueDate = _transdate; trandayInfo.Verified = true; trandayInfo.Verified_User = _channel.UserLogin; trandayInfo.DocID = base.GenerateDocId(); trandayInfo.Trace = trandayInfo.DocID; _dalTranday.CreateOneTranday(trandayInfo); D_TrandayDetail dalTrandaydetail; TrandayDetail_Info trandaydetailInfo; Account_Info ai = new Account_Info(); List <Account_Info> ac_list = new List <Account_Info>(); bool find_ac = false; D_TranCodeDetail dalTrancodedetail = new D_TranCodeDetail(); List <TranCodeDetail_Info> list = dalTrancodedetail.GetTranCodeDetailByCode(trancode); if (list == null) { _res.SetError("30", string.Format("Can't load trancodedetail: {0}", trancode)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } _dalTranday.ClearCommand(); return(_res); } foreach (TranCodeDetail_Info tcdi in list) { dalTrandaydetail = new D_TrandayDetail(); trandaydetailInfo = new TrandayDetail_Info(); switch (tcdi.CreditDebit) { case CreditDebit.DB: ac_list = _dalAc.GetListAccountLike(tcdi.Account_ID); foreach (Account_Info acInfo in ac_list) { if (db_account == acInfo.Account_ID) { find_ac = true; break; } } if (find_ac == false) { // không xác định được nhóm tài khoản khách hàng _res.SetError("31", string.Format("{0} not in group {1}", db_account, tcdi.Account_ID)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } _dalTranday.ClearCommand(); return(_res); } trandaydetailInfo.Account_ID = db_account; trandaydetailInfo.DB_Amount = amount; ai = _dalAc.GetOneAccount(trandaydetailInfo.Account_ID); // kiểm tra luật hạch toán if (!CheckAccountRules(ai, CreditDebit.DB, amount)) { _res.SetError("15", _msgRule); _dalTranday.ClearCommand(); return(_res); } // ghi nợ tài khoản. ai.y_Debit += amount; ai.q_Debit += amount; ai.m_Debit += amount; ai.w_Debit += amount; ai.d_Debit += amount; trandaydetailInfo.Ccy = ai.Ccy; break; case CreditDebit.CR: ac_list = _dalAc.GetListAccountLike(tcdi.Account_ID); foreach (Account_Info acInfo in ac_list) { if (cr_account == acInfo.Account_ID) { find_ac = true; break; } } if (find_ac == false) { // không xác định được nhóm tài khoản khách hàng _res.SetError("31", string.Format("{0} not in group {1}", cr_account, tcdi.Account_ID)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } _dalTranday.ClearCommand(); return(_res); } trandaydetailInfo.Account_ID = cr_account; trandaydetailInfo.CR_Amount = amount; ai = _dalAc.GetOneAccount(trandaydetailInfo.Account_ID); // kiểm tra luật hạch toán if (!CheckAccountRules(ai, CreditDebit.CR, amount)) { _res.SetError("15", _msgRule); _dalTranday.ClearCommand(); return(_res); } // ghi có tài khoản. ai.y_Credit += amount; ai.q_Credit += amount; ai.m_Credit += amount; ai.w_Credit += amount; ai.d_Credit += amount; trandaydetailInfo.Ccy = ai.Ccy; break; } trandaydetailInfo.SEQ = tcdi.SEQ; trandaydetailInfo.DocID = trandayInfo.DocID; // cập nhật số dư mới trandaydetailInfo.BalanceAvaiable = ai.BalanceAvaiable; // cập nhật thời gian ai.Last_Date = DateTime.Now; // thực hiện câu lệnh _dalTranday.AddCommand(dalTrandaydetail.CreateOneTrandayDetail(trandaydetailInfo)); _dalTranday.AddCommand(_dalAc.EditOneAccount(ai)); } if (string.IsNullOrEmpty(_docId)) { _docId = trandayInfo.DocID; } if (!string.IsNullOrEmpty(trancodeInfo.NextCode)) { Fundtransfer(trancodeInfo.NextCode, fromAccount, toAccount, amount, descript); } else // ghi nhận hạch toán if (!_dalTranday.Execute()) { _res.SetError("99", _dalTranday.GetException.Message); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } _docId = String.Empty; _dalTranday.ClearCommand(); } else // Lấy thông tin giao dịch { _res.Transactions = base.GetTrandayById(_docId).RenderXML(); _docId = String.Empty; } } catch (Exception ex) { _res.SetError("99", ex.Message); if (logger.IsErrorEnabled) { logger.Error(ex); } _docId = String.Empty; _dalTranday.ClearCommand(); } return(_res); }
/// <summary> /// chuyển khoản từ tài khoản db_account sang tài khoản cr_account /// (ghi nợ tài khoản db_account và ghi có tài khoản cr_account) /// </summary> /// <param name="amount">số tiền chuyển khoản</param> /// <param name="from_account">tài khoản ghi nợ</param> /// <param name="to_account">tài khoản ghi có</param> /// <returns> /// 0 không thành công /// 1 thành công /// </returns> public ResponseMessage FundTransfer(string trace, decimal amount, string db_account, string cr_account) { ResponseMessage msg = new ResponseMessage(); msg.LocalDate = DateTime.Now.ToString("MMdd"); msg.LocalTime = DateTime.Now.ToString("hhmmss"); D_Tranday dt = new D_Tranday(); // kiểm tra số chứng từ đã tồn tại hay chưa if (dt.IsExists("", trace)) { logger.Error(string.Format("Transaction {0} does exists", trace)); msg.ResponseCode = "12"; // Invalid transaction return(msg); } // kiểm tra hai tài khoản đã có hay chưa D_Account da = new D_Account(); if (da.GetOneAccount(db_account) == null) { logger.Error(string.Format("From account {0} does not found", db_account)); msg.ResponseCode = "78"; //No Account return(msg); } if (da.GetOneAccount(cr_account) == null) { logger.Error(string.Format("To account {0} does not found", cr_account)); msg.ResponseCode = "78"; //No Account return(msg); } // kiểm tra số dư chuyển khoản. Tranday_Info ti = new Tranday_Info(); ti.AllowReverse = true; ti.Branch_ID = branch_id; ti.Descript = string.Format("transfer from {0} to {1} with amount = {2}", db_account, cr_account, amount); ti.NextDocId = ""; ti.Status = TransactionStatus.Approved; ti.TranCode = fundtransfer_trancode; ti.TransDate = transdate; ti.UserCreate = user_id; ti.ValueDate = transdate; ti.Verified = true; ti.Verified_User = user_id; ti.Trace = trace; ti.DocID = base.GenerateDocId(); dt.CreateOneTranday(ti); D_TrandayDetail dtd; TrandayDetail_Info tdi; Account_Info ai = new Account_Info(); D_TranCodeDetail dcd = new D_TranCodeDetail(); List <TranCodeDetail_Info> list = dcd.GetTranCodeDetailByCode(fundtransfer_trancode); foreach (TranCodeDetail_Info tcdi in list) { dtd = new D_TrandayDetail(); tdi = new TrandayDetail_Info(); switch (tcdi.CreditDebit) { case CreditDebit.DB: if (db_account.IndexOf(tcdi.Account_ID) != 0) { // không xác định được nhóm tài khoản khách hàng if (logger.IsErrorEnabled) { logger.Error(string.Format("{0} not in group {1}", db_account, tcdi.Account_ID)); } msg.ResponseCode = "78"; //No Account return(msg); } tdi.Account_ID = db_account; tdi.DB_Amount = amount; ai = da.GetOneAccount(tdi.Account_ID); ai.y_Debit += amount; ai.q_Debit += amount; ai.m_Debit += amount; ai.w_Debit += amount; ai.d_Debit += amount; tdi.Ccy = ai.Ccy; break; case CreditDebit.CR: if (cr_account.IndexOf(tcdi.Account_ID) != 0) { // không xác định được nhóm tài khoản khách hàng if (logger.IsErrorEnabled) { logger.Error(string.Format("{0} not in group {1}", cr_account, tcdi.Account_ID)); } msg.ResponseCode = "78"; //No Account return(msg); } tdi.Account_ID = cr_account; tdi.CR_Amount = amount; ai = da.GetOneAccount(tdi.Account_ID); ai.y_Credit += amount; ai.q_Credit += amount; ai.m_Credit += amount; ai.w_Credit += amount; ai.d_Credit += amount; tdi.Ccy = ai.Ccy; break; } tdi.SEQ = tcdi.SEQ; tdi.DocID = ti.DocID; dt.AddCommand(dtd.CreateOneTrandayDetail(tdi)); dt.AddCommand(da.EditOneAccount(ai)); } if (dt.Execute() == true) { if (logger.IsDebugEnabled) { logger.Debug(string.Format("Done transfer from {0} to {1}", db_account, cr_account)); } msg.ResponseCode = "00"; //Approved return(msg); } else { if (logger.IsErrorEnabled) { logger.Error(string.Format("Fails transfer from {0} to {1}", db_account, cr_account)); } msg.ResponseCode = "06"; //Error return(msg); } }
public static int Update(Account_Info obj) { return(dal_ac.Update(obj)); }
public static int Insert(Account_Info obj) { return(dal_ac.Insert(obj)); }