Exemplo n.º 1
0
        public int losemoney(string shop_name)//购买物品减少金钱
        {
            SSHOP  shop1      = new SSHOP();
            PERSON person     = new PERSON();
            int    allmoney   = person.Tiqu_person_money();
            int    lose_money = shop1.Tiqu_shop_money(shop_name);

            if (allmoney >= lose_money)
            {
                sql.Open();
                string     lose_money1       = "update person set person_money-=" + lose_money;
                SqlCommand command_losemoney = new SqlCommand(lose_money1, sql);
                try
                {
                    command_losemoney.ExecuteNonQuery();
                }
                catch
                {
                    MessageBox.Show("减少金钱失败");
                }
                finally
                {
                    sql.Close();
                }
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SSHOP  shop   = new SSHOP();
            ATTACK aTTACK = new ATTACK();

            sql.Open();
            int           ID           = Convert.ToInt32(dataGridView1.CurrentCell.RowIndex) + 1;
            string        shopcheck    = "select *from shop where shop_id=" + ID;
            SqlCommand    command_shop = new SqlCommand(shopcheck, sql);
            SqlDataReader reader       = command_shop.ExecuteReader();

            while (reader.Read())
            {
                shop_item = reader.GetString(reader.GetOrdinal("itemname"));
            }
            reader.Close();
            if (shop.losemoney(shop_item) == 1)
            {
                aTTACK.bag_add(shop_item);
                MessageBox.Show("购买成功", "恭喜您");
            }
            else

            {
                MessageBox.Show("您的金钱不够哦");
            }

            sql.Close();
        }
Exemplo n.º 3
0
Arquivo: bag.cs Projeto: rmxob/xiangmu
        private void button1_Click(object sender, EventArgs e)
        {
            string a    = Convert.ToString(dataGridView1.CurrentCell.Value);
            SSHOP  shop = new SSHOP();


            try
            {
                shop.useitems(a);
                MessageBox.Show("使用物品成功");

                sql.Open();
                skinPictureBox1.Image = Image.FromFile("背包.jpg");
                string         str = " select *from bag ";
                DataTable      b   = new DataTable();
                SqlDataAdapter c   = new SqlDataAdapter(str, sql);
                c.Fill(b);
                dataGridView1.DataSource = b;
                sql.Close();
            }
            catch
            {
                MessageBox.Show("使用物品失败");
            }
        }