Exemple #1
0
        private void button8_Click(object sender, EventArgs e)
        {
            DBContext myDB = new DBContext();

            myDB.products.Load();
            StoreModels.Contact c = new StoreModels.Contact(); c = null;
            bool isPaid           = true;

            StoreModels.Check ch = new StoreModels.Check(); ch = null;
            var lst = myDB.products.ToList();

            if (lst.Count == 0)
            {
                MessageBox.Show("محصولی ثبت نشده");
                return;
            }

            List <StoreModels.ProductTransactionItem> listpti = new List <StoreModels.ProductTransactionItem>();

            for (int i = 0; i < lst.Count; i++)
            {
                StoreModels.ProductTransactionItem temp = new StoreModels.ProductTransactionItem()
                {
                    Product      = lst[i],
                    Count        = 3,
                    ItemPrice    = lst[0].SellPrice,
                    ItemDiscount = 0,
                };
                listpti.Add(temp);
            }

            Store myStore = new Store();

            myStore.sell(listpti, DateTime.Now, null, isPaid, c, ch);
        }
Exemple #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            StoreModels.Contact con = new StoreModels.Contact()
            {
                Name  = "Arash",
                Type  = StoreModels.Contact.Types.Person,
                Phone = "09355000000"
            };
            DBContext myDB = new DBContext();

            myDB.save(con);
        }
Exemple #3
0
        private void button20_Click(object sender, EventArgs e)
        {
            DBContext myDb = null;

            try
            {
                myDb = new DBContext();
                StoreModels.Contact c = myDb.contacts.Where(i => i.Code == 1).FirstOrDefault();
                myDb.contacts.Attach(c);
                myDb.delete(c);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }