Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            DBContext myDb = new DBContext();

            myDb.superCategories.Where(o => o.Name == "سوپر دسته1").Load();
            var scats = myDb.superCategories.ToList();

            StoreModels.SuperCategory sc;
            if (scats.Count == 0)
            {
                sc = new StoreModels.SuperCategory()
                {
                    Name = "سوپر دسته جدید"
                }
            }
            ;
            else
            {
                sc = scats[0];
            }

            StoreModels.Category c = new StoreModels.Category()
            {
                Name          = "دسته1",
                SuperCategory = sc
            };

            myDb.save(c);
        }
Beispiel #2
0
        private void button23_Click(object sender, EventArgs e)
        {
            DBContext myDb = null;

            try
            {
                myDb = new DBContext();
                myDb.products.Load();
                var lst = myDb.products.ToList();
                if (lst.Count == 0)
                {
                    //لیست خالی
                }
                else
                {
                    bool flag = false;
                    myDb.superCategories.Load();
                    var lst1 = myDb.superCategories.ToList();
                    for (int i = 0; i < lst1.Count; i++)
                    {
                        if (lst1[i].Name == "")
                        {
                            flag = true;
                        }
                        if (!flag)
                        {
                            StoreModels.SuperCategory sc = new StoreModels.SuperCategory()
                            {
                                Name = "سوپر دسته"
                            };
                            myDb.save(sc);
                        }
                    }
                    myDb.categories.Load();
                    var lst2 = myDb.categories.ToList();
                    for (int i = 0; i < lst1.Count; i++)
                    {
                        if (lst2[i].Name == "دسته1")
                        {
                            flag = true;
                        }
                        if (!flag)
                        {
                            StoreModels.Category c = new StoreModels.Category()
                            {
                                Name = "کالا"
                            };
                            myDb.save(c);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            StoreModels.SuperCategory sc = new StoreModels.SuperCategory()
            {
                Name = "سوپر دسته1"
            };
            DBContext myDb = new DBContext();

            myDb.save(sc);
        }
Beispiel #4
0
        private void button17_Click(object sender, EventArgs e)
        {
            DBContext myDb = null;

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