Ejemplo n.º 1
0
        /// <summary>
        /// 根据用户ID获取库存信息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>库存信息</returns>
        public static MoneyInventory GetMoneyInventoryByUserId(string userId)
        {
            MoneyInventory moneyInventory = new MoneyInventory();
            moneyInventory.StorageQuantity = new Storagequantity();
            moneyInventory.FdInfo = new Fundinfo();
            SqlConnection sqlconn = null;
            SqlCommand sqlcmd = null;
            SqlDataReader sqldr = null;

            try
            {
                moneyInventory.Result = false;
                bool IsGetMoney = false;
                sqlconn = new SqlConnection(SqlConnectionString);
                sqlconn.Open();
                sqlcmd = sqlconn.CreateCommand();
                sqlcmd.CommandText = "select DongJieMoney,money,frozenMoney,OccMoney,state,CashUser,SubUser,TanUser,ConBankType,OpenBank,BankAccount,AccountName,BankCard from Trade_FundInfo where state<>'4' and userId=@userId";
                SqlParameter lh = new SqlParameter();
                lh.ParameterName = "@userId";
                lh.DbType = DbType.String;
                lh.Value = userId;
                sqlcmd.Parameters.Add(lh);
                sqldr = sqlcmd.ExecuteReader();
                while (sqldr.Read())
                {
                    moneyInventory.FdInfo.DongJieMoney = System.DBNull.Value != sqldr["DongJieMoney"] ? Convert.ToDouble(sqldr["DongJieMoney"]) : 0;
                    moneyInventory.FdInfo.Money = System.DBNull.Value != sqldr["money"] ? Convert.ToDouble(sqldr["money"]) : 0;
                    moneyInventory.FdInfo.FrozenMoney = System.DBNull.Value != sqldr["frozenMoney"] ? Convert.ToDouble(sqldr["frozenMoney"]) : 0;
                    moneyInventory.FdInfo.OccMoney = System.DBNull.Value != sqldr["OccMoney"] ? Convert.ToDouble(sqldr["OccMoney"]) : 0;
                    moneyInventory.FdInfo.State = System.DBNull.Value != sqldr["state"] ? sqldr["state"].ToString() : string.Empty;
                    moneyInventory.FdInfo.CashUser = System.DBNull.Value != sqldr["CashUser"] ? sqldr["CashUser"].ToString() : string.Empty;
                    moneyInventory.FdInfo.SubUser = System.DBNull.Value != sqldr["SubUser"] ? sqldr["SubUser"].ToString() : string.Empty;
                    moneyInventory.FdInfo.TanUser = System.DBNull.Value != sqldr["TanUser"] ? sqldr["TanUser"].ToString() : string.Empty;
                    moneyInventory.FdInfo.ConBankType = System.DBNull.Value != sqldr["ConBankType"] ? sqldr["ConBankType"].ToString() : string.Empty;
                    moneyInventory.FdInfo.OpenBank = System.DBNull.Value != sqldr["OpenBank"] ? sqldr["OpenBank"].ToString() : string.Empty;
                    moneyInventory.FdInfo.BankAccount = System.DBNull.Value != sqldr["BankAccount"] ? sqldr["BankAccount"].ToString() : string.Empty;
                    moneyInventory.FdInfo.AccountName = System.DBNull.Value != sqldr["AccountName"] ? sqldr["AccountName"].ToString() : string.Empty;
                    moneyInventory.FdInfo.BankCard = System.DBNull.Value != sqldr["BankCard"] ? sqldr["BankCard"].ToString() : string.Empty;
                    IsGetMoney = true;
                    break;
                }
                ////没有获取资金
                //if (!IsGetMoney)
                //{
                //    return moneyInventory;
                //}
                ////查询 库存
                //sqldr.Close();
                //sqlcmd.CommandText = "select au,ag,pt,pd from Stock_BZJ where userId=@userId ";
                //sqldr = sqlcmd.ExecuteReader();
                //if (sqldr.Read())
                //{
                //    moneyInventory.StorageQuantity.xau = System.DBNull.Value != sqldr["au"] ? Convert.ToDouble(sqldr["au"]) : 0;

                //    moneyInventory.StorageQuantity.xag = System.DBNull.Value != sqldr["ag"] ? Convert.ToDouble(sqldr["ag"]) : 0;

                //    moneyInventory.StorageQuantity.xpt = System.DBNull.Value != sqldr["pt"] ? Convert.ToDouble(sqldr["pt"]) : 0;

                //    moneyInventory.StorageQuantity.xpd = System.DBNull.Value != sqldr["pd"] ? Convert.ToDouble(sqldr["pd"]) : 0;
                //}

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (null != sqlconn)
                {
                    sqlconn.Close();
                }
                if (null != sqldr)
                {
                    sqldr.Close();
                }
            }
            moneyInventory.Result = true;
            return moneyInventory;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 资金库存信息查询
        /// </summary>
        /// <param name="account">要被查询的账号</param>
        /// <param name="LoginID">登陆标识</param>
        /// <returns>资金库存信息</returns>
        public MoneyInventory GetMoneyInventoryEx(string account, string LoginID)
        {
            MoneyInventory moneyInventory = new MoneyInventory();
            moneyInventory.StorageQuantity = new Storagequantity();
            moneyInventory.FdInfo = new Fundinfo();

            System.Data.Common.DbDataReader dbreader = null;
            //bool IsGetMoney = false;
            try
            {
                string userId = string.Empty;
                moneyInventory.Result = false;
                //查看 logid在 数据库 存在否
                //if (!ComFunction.ExistUserLoginID(LoginID))
                //{
                //    moneyInventory.Result = false;
                //    moneyInventory.ReturnCode = ResCode.UL003;
                //    moneyInventory.Desc = ResCode.UL003Desc;
                //    return moneyInventory;
                //}
                userId = ComFunction.GetUserId(account);
                if (string.IsNullOrEmpty(userId))//如果用户不存在
                {
                    moneyInventory.Result = false;
                    moneyInventory.ReturnCode = ResCode.UL005;
                    moneyInventory.Desc = ResCode.UL005Desc;
                    return moneyInventory;
                }
                string sql = "select DongJieMoney,money,frozenMoney,OccMoney,state,CashUser,SubUser,TanUser,ConBankType,OpenBank,BankAccount,AccountName,BankCard from Trade_FundInfo where state<>'4' and userId=@userId";

                dbreader = DbHelper.ExecuteReader(sql,
                    new System.Data.Common.DbParameter[]{DbHelper.CreateDbParameter(JinTong.Jyrj.Data.DataBase.Type,
                    "@userId",DbParameterType.String,userId,ParameterDirection.Input)});
                while (dbreader.Read())
                {
                    moneyInventory.FdInfo.DongJieMoney = System.DBNull.Value != dbreader["DongJieMoney"] ? Convert.ToDouble(dbreader["DongJieMoney"]) : 0;
                    moneyInventory.FdInfo.Money = System.DBNull.Value != dbreader["money"] ? Convert.ToDouble(dbreader["money"]) : 0;
                    moneyInventory.FdInfo.FrozenMoney = System.DBNull.Value != dbreader["frozenMoney"] ? Convert.ToDouble(dbreader["frozenMoney"]) : 0;
                    moneyInventory.FdInfo.OccMoney = System.DBNull.Value != dbreader["OccMoney"] ? Convert.ToDouble(dbreader["OccMoney"]) : 0;
                    moneyInventory.FdInfo.State = System.DBNull.Value != dbreader["state"] ? dbreader["state"].ToString() : string.Empty;
                    moneyInventory.FdInfo.CashUser = System.DBNull.Value != dbreader["CashUser"] ? dbreader["CashUser"].ToString() : string.Empty;
                    moneyInventory.FdInfo.SubUser = System.DBNull.Value != dbreader["SubUser"] ? dbreader["SubUser"].ToString() : string.Empty;
                    moneyInventory.FdInfo.TanUser = System.DBNull.Value != dbreader["TanUser"] ? dbreader["TanUser"].ToString() : string.Empty;
                    moneyInventory.FdInfo.ConBankType = System.DBNull.Value != dbreader["ConBankType"] ? dbreader["ConBankType"].ToString() : string.Empty;
                    moneyInventory.FdInfo.OpenBank = System.DBNull.Value != dbreader["OpenBank"] ? dbreader["OpenBank"].ToString() : string.Empty;
                    moneyInventory.FdInfo.BankAccount = System.DBNull.Value != dbreader["BankAccount"] ? dbreader["BankAccount"].ToString() : string.Empty;
                    moneyInventory.FdInfo.AccountName = System.DBNull.Value != dbreader["AccountName"] ? dbreader["AccountName"].ToString() : string.Empty;
                    moneyInventory.FdInfo.BankCard = System.DBNull.Value != dbreader["BankCard"] ? dbreader["BankCard"].ToString() : string.Empty;
                    //IsGetMoney = true;
                    break;
                }
                //if (!IsGetMoney)
                //{
                //    return moneyInventory;
                //}
                //查询 库存
                dbreader.Close();
                //sqlcmd.CommandText = "select au,ag,pt,pd from Stock_BZJ where userId=@userId ";
                //sqldr = sqlcmd.ExecuteReader();
                //if (sqldr.Read())
                //{
                //    moneyInventory.StorageQuantity.xau = System.DBNull.Value != sqldr["au"] ? Convert.ToDouble(sqldr["au"]) : 0;

                //    moneyInventory.StorageQuantity.xag = System.DBNull.Value != sqldr["ag"] ? Convert.ToDouble(sqldr["ag"]) : 0;

                //    moneyInventory.StorageQuantity.xpt = System.DBNull.Value != sqldr["pt"] ? Convert.ToDouble(sqldr["pt"]) : 0;

                //    moneyInventory.StorageQuantity.xpd = System.DBNull.Value != sqldr["pd"] ? Convert.ToDouble(sqldr["pd"]) : 0;
                //}
                moneyInventory.Result = true;
            }
            catch (Exception ex)
            {
                ComFunction.WriteErr(ex);
                moneyInventory.Result = false;
            }
            finally
            {
                if (null != dbreader)
                {
                    dbreader.Close();
                    dbreader.Dispose();
                }
            }
            return moneyInventory;
        }