Esempio n. 1
0
 public string Swift(Swift swift)
 {
     Trans tran = new Trans();
     tran.Amount = swift.Payer_Amount;
     tran.From = swift.Payer_Account_Num;
     MysqlHelper mysqlhelper = new MysqlHelper();
     var status1 = mysqlhelper.ChecktheAccount(ref tran);
     if (status1 != "success")
         return status1;
     var status =  mysqlhelper.OverSeaTrans(swift);
     return status;
 }
Esempio n. 2
0
        public string CheckAndChange(Trans trans)
        {
            MysqlHelper mysqlhelper = new MysqlHelper();
            var status = mysqlhelper.ChecktheAccount(ref trans);
            if (status == "success")
            {

                return mysqlhelper.UpdateAccount(trans);
            }
            else
            {
                return status;
            }
        }
Esempio n. 3
0
 public string Repayment([FromBody] Repay repayment)
 {
     Trans trans = new Trans();
     trans.From = repayment.Repay_Account;
     trans.Amount = repayment.Amount;
     trans.To = repayment.Credit_Account;
     trans.User_Id = repayment.User_Id;
     trans.Type = repayment.Type;
        // return "Success";
     MysqlHelper mysqlhelper = new MysqlHelper();
     var status = mysqlhelper.ChecktheAccount(ref trans);
     if (status == "success")
     {
         mysqlhelper.PushToRepayLog(repayment);
         return mysqlhelper.UpdateAccount(trans);
     }
     else
     {
         return status;
     }
 }
Esempio n. 4
0
        internal string CheckTheInnerAccount(Trans trans)
        {
            string sql = string.Format("select * from saving_account where card_num = '{0}'", trans.To);
            string error = null;
            MySqlConnection conn = null;
            try
            {
                conn = new MySqlConnection(connStr_local);
                conn.Open();
                MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
                // 创建DataSet,用于存储数据.
                DataSet testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");

                if (testDataSet != null && testDataSet.Tables["result_data"] != null && testDataSet.Tables["result_data"].Rows != null && testDataSet.Tables["result_data"].Rows.Count > 0)
                {
                    return "1";

                }
                else
                {
                    return "6";
                }
            }
            catch (Exception t)
            {
                return "6";
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 5
0
        internal string ChecktheAccount(ref Trans tran)
        {
            string sql = string.Format("select * from saving_account where card_num='{0}'", tran.From);
            DataSet testDataSet = null;
            MySqlConnection conn = new MySqlConnection(connStr_local);
            try
            {
                conn.Open();
                // 创建一个适配器
                MySqlDataAdapter adapter = new MySqlDataAdapter(sql, conn);
                // 创建DataSet,用于存储数据.
                testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");
            }
            // 关闭数据库连接.
            catch (Exception e)
            {
                //log4net.ILog log = log4net.LogManager.GetLogger("MyLogger");
                //log.Debug(e.Message);
                Console.WriteLine(e.Message);
                //Console.ReadLine();

            }
            finally
            {
                conn.Close();
            }
            if (testDataSet != null && testDataSet.Tables["result_data"] != null && testDataSet.Tables["result_data"].Rows != null && testDataSet.Tables["result_data"].Rows.Count > 0)
            {
                if (Convert.ToInt32(testDataSet.Tables["result_data"].Rows[0]["balance"].ToString())>=Convert.ToInt32(tran.Amount))
                {
                    tran.Currency = testDataSet.Tables["result_data"].Rows[0]["currency_id"].ToString();
                    return "success";
                }
                else
                {

                    return "Insufficient balance";
                }
            }
            else
            {
                return "error";
            }
        }
Esempio n. 6
0
        internal string UpdateAccount(Trans trans)
        {
            string sql_1 = string.Format("insert into consumption_log set account='{0}',to_account='{1}',amount='{2}',type='{4}',user_id='{3}', currency='{5}';", trans.From, trans.To, trans.Amount, trans.User_Id, trans.Type,trans.Currency);
            string sql_2 = string.Format("update saving_account set balance= balance-'{0}' where card_num='{1}';", trans.Amount,trans.From);
            string sql_3 = string.Format("update credit_account set available_credit= available_credit+{0} where card_num='{1}';", trans.Amount,trans.To);
            string sql_4 = string.Format("insert into consumption_log set account='{0}',amount='{1}',type='{3}',user_id='{2}', currency='{4}';", trans.To,trans.Amount, trans.User_Id,"8", trans.Currency);
            string error = null;
            MySqlConnection conn = null;
            try
            {
                conn = new MySqlConnection(connStr_local);
                conn.Open();
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                if (trans.Type == "4")
                {

                    adapter = new MySqlDataAdapter(sql_1 + sql_2 + sql_3 + sql_4, conn);
                }
                else
                {
                    if (trans.Type == "6")
                    {
                        adapter = new MySqlDataAdapter(sql_2, conn);
                    }
                    else
                    {
                        adapter = new MySqlDataAdapter(sql_1 + sql_2, conn);
                    }
                }
                // 创建DataSet,用于存储数据.
                DataSet testDataSet = new DataSet();
                // 执行查询,并将数据导入DataSet.
                adapter.Fill(testDataSet, "result_data");
                return "Success";
            }
            catch (Exception t)
            {
                return "Error";
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 7
0
 internal string TransPush(Trans trans)
 {
     string sql_1 = string.Format("insert into consumption_log set account='{0}',to_account='{1}',amount='{2}',type='{4}',user_id='{3}',currency='{5}';", trans.From,trans.To,trans.Amount,trans.User_Id,trans.Type,trans.Currency);
        string sql_2 = string.Format("insert into trans_log set tr_from='{0}',tr_to='{1}',amount='{2}',type='{4}',user_id='{3}';", trans.From, trans.To, trans.Amount, trans.User_Id, trans.Type);
     string sql_3 = "";
     string sql_4 = "";
     if (trans.Type == "1")
     {
         sql_1 = "";
         sql_2 = string.Format("insert into trans_log set tr_from='{0}',tr_to='{1}',amount='{2}',type='{4}',user_id='{3}',status='2';", trans.From, trans.To, trans.Amount, trans.User_Id, trans.Type);
         sql_3 = string.Format("update saving_account set balance = balance+{0} where card_num='{1}';",trans.Amount,trans.To);
         sql_4 = string.Format("insert into consumption_log set account='{0}',amount='{1}',type='{3}',user_id='{2}',currency='{4}',from_account='{5}';", trans.To, trans.Amount, trans.User_Id, "2", trans.Currency,trans.From);
     }
     string error = null;
     MySqlConnection conn = null;
     try
     {
         conn = new MySqlConnection(connStr_local);
         conn.Open();
         MySqlDataAdapter adapter = new MySqlDataAdapter(sql_1+sql_2+sql_3+sql_4, conn);
         // 创建DataSet,用于存储数据.
         DataSet testDataSet = new DataSet();
         // 执行查询,并将数据导入DataSet.
         adapter.Fill(testDataSet, "result_data");
         return "Success";
     }
     catch (Exception t)
     {
         return "error";
     }
     finally
     {
         conn.Close();
     }
 }