private void OnRecvSellMarketItem(IChannel channel, Message message)
        {
            SSellMarketItem msg = message as SSellMarketItem;

            World.Instance.fPlayer.inventory.Remove(msg.item.ditem.item_id);
            GameObject.FindObjectOfType <MarketSellViewUI>().RefreshItems();
        }
        private void OnRecvSellMarketItem(IChannel channel, Message message)
        {
            CSellMarketItem request = message as CSellMarketItem;
            var             player  = (Player)channel.GetContent();

            using (var conn = GameDataBase.GetConnection())
            {
                using (var trans = conn.BeginTransaction())
                {
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "Select item_id From Item Where item_id=@item_id And status='Storing' And player_id=@player_id;";
                        cmd.Parameters.AddWithValue("item_id", request.item.ditem.item_id);
                        cmd.Parameters.AddWithValue("player_id", player.player_id);
                        var res = cmd.ExecuteScalar();
                        if (res == null)
                        {
                            trans.Rollback();
                            ClientTipInfo(channel, "Error! Try again.[Sell]");
                            return;
                        }
                    }
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "Update Item Set status='Selling' Where item_id=@item_id;";
                        cmd.Parameters.AddWithValue("item_id", request.item.ditem.item_id);
                        var res = cmd.ExecuteNonQuery();
                        if (res != 1)
                        {
                            trans.Rollback();
                            ClientTipInfo(channel, "Error! Try again.[Sell1]");
                            return;
                        }
                    }
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText =
                            "Insert Into Market(market_id, item_id, seller_id, price, price_type, valid)" +
                            "Values(DEFAULT, @item_id, @seller_id, @price, @price_type, @valid);";
                        cmd.Parameters.AddWithValue("item_id", request.item.ditem.item_id);
                        cmd.Parameters.AddWithValue("seller_id", player.player_id);
                        cmd.Parameters.AddWithValue("price", request.item.costConf.cost);
                        cmd.Parameters.AddWithValue("price_type", request.item.costConf.costType.ToString());
                        cmd.Parameters.AddWithValue("valid", true);
                        var res = cmd.ExecuteNonQuery();
                        if (res != 1)
                        {
                            trans.Rollback();
                            ClientTipInfo(channel, "Error! Try again.[Sell2]");
                            return;
                        }
                    }
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "Update Player Set items_count=items_count-1 Where player_id=@player_id;";
                        cmd.Parameters.AddWithValue("player_id", player.player_id);
                        var res = cmd.ExecuteNonQuery();
                        if (res != 1)
                        {
                            trans.Rollback();
                            ClientTipInfo(channel, "Error! Try again.[Sell3]");
                            return;
                        }
                    }
                    trans.Commit();
                } // trans
            }     //conn
            SSellMarketItem response = new SSellMarketItem();

            response.item = request.item;
            channel.Send(response);
            player.inventory.Remove(request.item.ditem.item_id);
            return;
        }