Esempio n. 1
0
 public TreasureMall FromDTreasureMall(DTreasureMall dTreasureMall)
 {
     this.price     = dTreasureMall.price;
     this.ownerName = dTreasureMall.ownerName;
     this.isGold    = dTreasureMall.isGold;
     return(this);
 }
Esempio n. 2
0
        private void OnRecvSellGold(IChannel channel, Message message)
        {
            Console.WriteLine("OnRecvSellGold");
            CSellGold request = message as CSellGold;
            Player    player  = (Player)channel.GetContent();
            ConnectDB connect = new ConnectDB();
            int       result;

            string goodsName  = request.goods;
            string playerName = player.user;
            int    goodPrice  = request.price;

            // delete from package
            result = connect.DBDeleteFromPackage(playerName, goodsName);
            if (result == 0)
            {
                Console.WriteLine("delete gold goods from package failure");
            }

            // add to mall
            DTreasureMall tmp = new DTreasureMall()
            {
                ownerName = playerName, price = goodPrice, isGold = true
            };

            backMall.Add(goodsName, tmp);
            result = connect.DBAddToMall(goodsName, playerName, true, goodPrice);
            if (result == 0)
            {
                Console.WriteLine("add gold goods to mall failure");
            }
        }
Esempio n. 3
0
        public Dictionary <string, DTreasureMall> DBGetMall()
        {
            NpgsqlConnection conn = new NpgsqlConnection(connStr);
            Dictionary <string, DTreasureMall> result = new Dictionary <string, DTreasureMall>();

            using (conn)
            {
                NpgsqlCommand objCommand = new NpgsqlCommand(GetMallSQL, conn);
                conn.Open();

                DbDataReader reader = objCommand.ExecuteReader();

                while (reader.Read())
                {
                    DTreasureMall tmp = new DTreasureMall()
                    {
                        ownerName = reader.GetString(reader.GetOrdinal("ownername")).Trim(),
                        price     = reader.GetInt32(reader.GetOrdinal("price")),
                        isGold    = reader.GetBoolean(reader.GetOrdinal("isgold"))
                    };
                    result.Add(reader.GetString(reader.GetOrdinal("treasurename")).Trim(), tmp);
                }
                ;

                return(result);
            }
        }
Esempio n. 4
0
        public DTreasureMall ToTreasureMall()
        {
            DTreasureMall treasureMall = new DTreasureMall()
            {
                ownerName = this.ownerName,
                price     = this.price,
                isGold    = this.isGold
            };

            return(treasureMall);
        }