Esempio n. 1
0
        void update()
        {
            MidDataBaseEntities dbContext = new MidDataBaseEntities();
            var q = (from p in dbContext.tMember
                     where p.fId.Equals(Member.fId)
                     select p).FirstOrDefault();

            lblGold.Text = q.fGold.ToString();
        }
Esempio n. 2
0
        void addNPC()
        {
            MidDataBaseEntities dbContext = new MidDataBaseEntities();
            var q = (from p in dbContext.tNPC
                     where p.fID.Equals(1)//id寫死
                     select p).FirstOrDefault();

            Copper.fName = q.fName;
            Copper.fGold = q.fGold;
        }
Esempio n. 3
0
        private void Shop_Load(object sender, EventArgs e)
        {
            MidDataBaseEntities dbContext = new MidDataBaseEntities();
            var q = (from p in dbContext.tShop
                     where p.fID == 3
                     select p).FirstOrDefault();

            Sshop.fName  = q.fName;
            Sshop.fPrice = q.fPrice;

            lblShop1Name.Text  = Sshop.fName;
            lblShop1Price.Text = Sshop.fPrice.ToString();
            pbxSHOP1.Image     = Image.FromFile(q.fPhoto);
        }
Esempio n. 4
0
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            MidDataBaseEntities dbContext = new MidDataBaseEntities();

            if (listBox1.Items.Count == 0)
            {
                return;
            }
            if (MessageBox.Show("請問是否購買?", "是否購買", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            var q = (from p in dbContext.tMember
                     where p.fId.Equals(Member.fId)
                     select p).FirstOrDefault();

            if (q.fGold < Sshop.fPrice)
            {
                MessageBox.Show("金額不足");
                return;
            }
            q.fGold = q.fGold - Sshop.fPrice;

            dbContext.SaveChanges();

            Form f = Application.OpenForms["Main"];

            ((Main)f).lblGold.Text = q.fGold.ToString(); //同步更新


            //==============================================
            var q1 = (from p in dbContext.tShop
                      where p.fID.Equals(3)
                      select p).FirstOrDefault();

            itemform.Ssop.fID   = q1.fID;
            itemform.Member.fId = q.fId;

            itemform.TopLevel = false;
            itemform.Dock     = DockStyle.Fill;
            panel1.Controls.Add(itemform);//
            itemform.Show();
            //==============================================
        }
Esempio n. 5
0
        private void Item_Load(object sender, EventArgs e)
        {
            MidDataBaseEntities dbContext = new MidDataBaseEntities();
            var q = (from p in dbContext.fItemBox
                     from c in dbContext.tShop
                     from m in dbContext.tMember
                     where p.fID == Member.fId && p.fID == c.fID
                     select c).FirstOrDefault();

            for (int i = 1; i < 3; i++)
            {
                for (int j = 1; j < 5; j++)
                {
                    PictureBox btn1 = new PictureBox();
                    btn1.Height      = 50;
                    btn1.Width       = 50;
                    btn1.Location    = new Point(20 + 60 * (j - 1), 50 + 60 * (i - 1));
                    btn1.Name        = "btn" + j;
                    btn1.Text        = btn1.Name;
                    btn1.BorderStyle = BorderStyle.Fixed3D;
                    this.Controls.Add(btn1);
                    if (i == 2)
                    {
                        btn1.Name        = "btn" + (j + 4);
                        btn1.Text        = btn1.Name;
                        btn1.BorderStyle = BorderStyle.Fixed3D;
                        this.Controls.Add(btn1);
                    }
                    if (btn1.Name == "btn1" && q != null)
                    {
                        btn1.Image    = Image.FromFile(q.fPhoto);
                        btn1.SizeMode = PictureBoxSizeMode.Zoom;
                    }
                }
            }

            InitializeTimer();
        }
Esempio n. 6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (Ssop.fID == 0 || Member.fId == 0)
            {
                return;
            }

            MidDataBaseEntities dbContext = new MidDataBaseEntities();

            IitemBox.fID       = Ssop.fID;
            IitemBox.fMemberID = Member.fId;
            dbContext.fItemBox.Add(IitemBox);
            dbContext.SaveChanges();
            if (IitemBox.fID > 0)
            {
                timer1.Enabled = false;
            }
            //if (Ssop.fID == 0)
            //{
            //    timer1.Enabled = true;
            //}
            //================================================
        }
Esempio n. 7
0
        private void btnAddGold(object sender, EventArgs e)
        {
            addNPC();
            MidDataBaseEntities dbContext = new MidDataBaseEntities();
            var q = (from p in dbContext.tMember
                     where p.fId.Equals(Member.fId)
                     select p).FirstOrDefault();

            q.fGold = q.fGold + Copper.fGold;

            lblGold.Text = q.fGold.ToString();

            dbContext.SaveChanges();
            //if (NowFrom == InformationForm)//如果是開個人資料頁面
            //{
            //    Form f = Application.OpenForms["Information"];
            //    ((Information)f).lblGold.Text = q.fGold.ToString(); //同步更新
            //}
            //else if (NowFrom == ItemForm)//如果是開物品欄頁面
            //{
            //    Form f = Application.OpenForms["Item"];
            //    ((Item)f).lblGold.Text = q.fGold.ToString(); //同步更新
            //}
        }