Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName">""表示所有玩家</param>
        /// <returns></returns>
        public LockSellStonesOrder[] GetLockSellStonesOrderList(string sellerUserName, string orderNumber, string buyUserName, int orderState)
        {
            LockSellStonesOrder[] orders = null;
            MySqlConnection       myconn = MyDBHelper.Instance.CreateConnection();

            try
            {
                DataTable table = new DataTable();

                myconn = MyDBHelper.Instance.CreateConnection();
                myconn.Open();
                MySqlCommand mycmd = myconn.CreateCommand();

                string sqlTextA = "select l.*, s.*, f.CreditValue as SellerCreditValue, f.Exp as SellerExpValue " +
                                  "from locksellstonesorder l " +
                                  "left join sellstonesorder s on s.OrderNumber = l.OrderNumber " +
                                  "left join playerfortuneinfo f on f.userId = (select u.id from playersimpleinfo u where u.UserName = s.SellerUserName)";

                StringBuilder builder = new StringBuilder();
                if (!string.IsNullOrEmpty(sellerUserName))
                {
                    builder.Append(" s.SellerUserName = @SellerUserName ");
                    string encryptSellerUserName = DESEncrypt.EncryptDES(sellerUserName);
                    mycmd.Parameters.AddWithValue("@SellerUserName", encryptSellerUserName);
                }
                if (!string.IsNullOrEmpty(orderNumber))
                {
                    if (builder.Length > 0)
                    {
                        builder.Append(" and ");
                    }
                    builder.Append(" s.OrderNumber = @OrderNumber ");
                    mycmd.Parameters.AddWithValue("@OrderNumber", orderNumber);
                }
                if (!string.IsNullOrEmpty(buyUserName))
                {
                    if (builder.Length > 0)
                    {
                        builder.Append(" and ");
                    }
                    builder.Append(" l.LockedByUserName = @BuyerUserName ");
                    string encryptUserName = DESEncrypt.EncryptDES(buyUserName);
                    mycmd.Parameters.AddWithValue("@BuyerUserName", encryptUserName);
                }
                if (orderState > 0)
                {
                    if (builder.Length > 0)
                    {
                        builder.Append(" and ");
                    }
                    builder.Append(" s.OrderState = @OrderState ");
                    mycmd.Parameters.AddWithValue("@OrderState", orderState);
                }
                string sqlWhere = "";
                if (builder.Length > 0)
                {
                    sqlWhere = " where " + builder.ToString();
                }

                string sqlAllText = sqlTextA + sqlWhere;
                mycmd.CommandText = sqlAllText;
                MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd);
                adapter.Fill(table);
                if (table != null)
                {
                    orders = MetaDBAdapter <LockSellStonesOrder> .GetLockStonesOrderListFromDataTable(table);
                }
                table.Clear();
                table.Dispose();
                adapter.Dispose();

                mycmd.Dispose();

                return(orders);
            }
            finally
            {
                MyDBHelper.Instance.DisposeConnection(myconn);
            }
        }