Ejemplo n.º 1
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();
            //==============================================
        }
Ejemplo n.º 2
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;
            //}
            //================================================
        }
Ejemplo n.º 3
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(); //同步更新
            //}
        }