Example #1
0
 public MainForm()
 {
     InitializeComponent();
     player  = (PlayerBean)Data.Get("player");
     world   = (WorldBean)Data.Get("world");
     account = (BankAccountBean)Data.Get("account");
 }
Example #2
0
        private void ButtonEnterWorld_Click(object sender, System.EventArgs e)
        {
            PlayerBean      player  = (PlayerBean)comboBoxSelectPlayer.SelectedItem;
            WorldBean       world   = (WorldBean)comboBoxSelectWorld.SelectedItem;
            BankAccountBean account = bankAccountDAO.GetByPlayerIdAndWorldId(player.Id, world.Id);

            if (player == null)
            {
                MessageBox.Show("请选择玩家");
                return;
            }
            if (world == null)
            {
                MessageBox.Show("请选择世界");
                return;
            }
            if (account == null)
            {
                account = new BankAccountBean()
                {
                    PlayerId = player.Id,
                    WorldId  = world.Id
                };
                bankAccountDAO.Insert(account);
            }
            Data.Set("player", player);
            Data.Set("world", world);
            Data.Set("account", account);
            Data.Set("system_account", bankAccountDAO.GetById(0));
            Data.Set("form", new MainForm());
            Dispose();
        }
Example #3
0
        private void ButtonCreateWorld_Click(object sender, System.EventArgs e)
        {
            if (comboBoxSelectWorld.Text.Length == 0)
            {
                MessageBox.Show("世界名称不能为空");
                return;
            }
            WorldBean world = new WorldBean
            {
                Name = comboBoxSelectWorld.Text
            };
            int result = worldDAO.Insert(world);

            if (result > 0)
            {
                MessageBox.Show("创建成功");
                comboBoxSelectWorld.Items.Add(world);
                comboBoxSelectWorld.SelectedItem = world;
            }
            else
            {
                MessageBox.Show("创建失败");
            }
        }
Example #4
0
        public List <ShopRecordBean> GetAll(DateTime start, DateTime end, PlayerBean player, WorldBean world)
        {
            MySqlConnection conn = DBUtils.GetConnection();
            MySqlCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = "select r.id as record_id, r.amount as record_amount, r.type as record_type, r.time as record_time, i.first_id as item_first_id, i.second_id as item_second_id, i.name as item_name, i.english_name as item_english_name, i.price as item_price, i.group_amount as item_group_amount from tb_shop_record r left join tb_shop_item i on r.item_first_id = i.first_id and r.item_second_id = i.second_id where r.player_id = @playerId and r.world_id = @worldId and r.time > @startTime and r.time < @endTime order by r.time desc";
            cmd.Parameters.AddWithValue("@playerId", player.Id);
            cmd.Parameters.AddWithValue("@worldId", player.Id);
            cmd.Parameters.AddWithValue("@startTime", start);
            cmd.Parameters.AddWithValue("@endTime", end);
            MySqlDataReader       reader  = cmd.ExecuteReader();
            List <ShopRecordBean> records = new List <ShopRecordBean>();

            while (reader.Read())
            {
                ShopRecordBean record = new ShopRecordBean
                {
                    Id           = reader.GetInt64("record_id"),
                    PlayerId     = player.Id,
                    WorldId      = world.Id,
                    ItemFirstId  = reader.GetInt32("item_first_id"),
                    ItemSecondId = reader.GetInt32("item_second_id"),
                    ItemName     = reader.GetString("item_name"),
                    Amount       = reader.GetInt32("record_amount"),
                    Type         = reader.GetInt32("record_type"),
                    Time         = reader.GetDateTime("record_time")
                };
                records.Add(record);
            }
            reader.Close();
            DBUtils.CloseConnection(conn);
            return(records);
        }