Exemplo n.º 1
0
        public void ObjeIslemler2(ObjectEnum objectEnum, ObjectIslem objectIslem, object obje, int iliskiliObjeId, GridControl gridControl)
        {
            switch (objectEnum)
            {
            case ObjectEnum.Marka:
                var            brand = (DataRowView)obje;
                PRODUCT_BRANDS productBrand;
                BindingSource  bi = new BindingSource();
                switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    /*  productBrand = new PRODUCT_BRANDS
                     * {
                     *    BRAND_NAME = (string) brand["Marka"]
                     * };
                     * _dbproductContext.PRODUCT_BRANDS.Add(productBrand);
                     */

                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Guncelle:
                    int id = (int)brand["Id"];
                    productBrand            = _dbproductContext.PRODUCT_BRANDS.FirstOrDefault(b => b.BRAND_ID == id);
                    productBrand.BRAND_NAME = brand["Marka"].ToString();
                    _dbproductContext.Entry(productBrand).State = System.Data.Entity.EntityState.Modified;
                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Listele:

                    _dbproductContext.PRODUCT_BRANDS.Load();
                    // This line of code is generated by Data Source Configuration Wizard

                    bi.DataSource          = _dbproductContext.PRODUCT_BRANDS.Local.ToBindingList();
                    gridControl.DataSource = bi;

                    /*  List<MyGridView> objeList = (from pbs in _dbproductContext.PRODUCT_BRANDS
                     *                              select new MyGridView()
                     *                         {
                     *                             Id= pbs.BRAND_ID,Deger = pbs.BRAND_NAME,
                     *                             kolonAdi = ObjectEnum.Marka.ToString()
                     *                         }
                     *   ).ToList();
                     *
                     * ds = new DataSet();
                     * ds.Tables.Add(GetDataSource(objeList));
                     * gridControl.DataSource = ds.Tables[0];*/
                    break;
                }
                break;

            case ObjectEnum.Model:
                var model = (DataRowView)obje;
                PRODUCT_BRANDS_MODEL productBrandsModel;
                switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    productBrandsModel = new PRODUCT_BRANDS_MODEL {
                        BRAND_ID = iliskiliObjeId, MODEL_NAME = (string)model[objectEnum.ToString()]
                    };
                    _dbproductContext.PRODUCT_BRANDS_MODEL.Add(productBrandsModel);
                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Guncelle:
                    int id = (int)model["Id"];
                    productBrandsModel            = _dbproductContext.PRODUCT_BRANDS_MODEL.FirstOrDefault(b => b.MODEL_ID == id);
                    productBrandsModel.MODEL_NAME = model[objectEnum.ToString()].ToString();

                    _dbproductContext.Entry(productBrandsModel).State = System.Data.Entity.EntityState.Modified;
                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Listele:
                    _dbproductContext.PRODUCT_BRANDS.Load();
                    // This line of code is generated by Data Source Configuration Wizard

                    gridControl.DataSource = _dbproductContext.PRODUCT_BRANDS.Local.ToBindingList();
                    List <MyGridView> objeList = (from pbs in _dbproductContext.PRODUCT_BRANDS_MODEL
                                                  select new MyGridView()
                    {
                        // Id = pbs.BRAND_ID,
                        Id = pbs.MODEL_ID,
                        Deger = pbs.MODEL_NAME,
                        kolonAdi = objectEnum.ToString()
                    }
                                                  ).ToList();
                    ds = new DataSet();
                    ds.Tables.Add(GetDataSource(objeList));
                    gridControl.DataSource = ds.Tables[0];
                    break;
                }
                break;

            case ObjectEnum.Birim:
                var        birim = (Birim)obje;
                SETUP_UNIT setupUnit;
                switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    setupUnit = new SETUP_UNIT {
                        UNIT_ID = birim.BirimId, UNIT = birim.BirimAd
                    };
                    _dbproductContext.SETUP_UNIT.Add(setupUnit);
                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Guncelle:
                    setupUnit      = _dbproductContext.SETUP_UNIT.FirstOrDefault(b => b.UNIT_ID == birim.BirimId);
                    setupUnit.UNIT = birim.BirimAd;

                    _dbproductContext.Entry(setupUnit).State = System.Data.Entity.EntityState.Modified;
                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Listele:
                    List <Birim> objeList = (from pbs in _dbproductContext.SETUP_UNIT
                                             select new Birim()
                    {
                        BirimId = pbs.UNIT_ID,
                        BirimAd = pbs.UNIT
                    }
                                             ).ToList();
                    var bindingSource = new BindingSource(objeList, null);
                    gridControl.DataSource = bindingSource;
                    break;
                }
                break;

            case ObjectEnum.UrunKategori:
                var         productCat_ = (UrunKategori)obje;
                PRODUCT_CAT productCat;
                switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    productCat = new PRODUCT_CAT {
                        PRODUCT_CATID = productCat_.KategoriId, PRODUCT_CAT1 = productCat_.Kategori, HIERARCHY = productCat_.KategoriKodu
                    };
                    _dbproductContext.PRODUCT_CAT.Add(productCat);
                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Guncelle:
                    productCat = _dbproductContext.PRODUCT_CAT.FirstOrDefault(b => b.PRODUCT_CATID == productCat_.KategoriId);
                    productCat.PRODUCT_CAT1 = productCat_.Kategori;
                    productCat_.Hiyerarsi   = productCat_.Hiyerarsi;

                    _dbproductContext.Entry(productCat).State = System.Data.Entity.EntityState.Modified;
                    _dbproductContext.SaveChanges();
                    break;

                case ObjectIslem.Listele:
                    List <UrunKategori> objeList = (from pbs in _dbproductContext.PRODUCT_CAT
                                                    select new UrunKategori()
                    {
                        KategoriId = pbs.PRODUCT_CATID,
                        Kategori = pbs.PRODUCT_CAT1,
                        KategoriKodu = pbs.HIERARCHY
                    }
                                                    ).ToList();
                    var bindingSource = new BindingSource(objeList, null);
                    gridControl.DataSource = bindingSource;
                    break;
                }
                break;
            }
        }
Exemplo n.º 2
0
        public void ObjeIslemler(ObjectEnum objectEnum, ObjectIslem objectIslem, object obje, int iliskiliObjeId, GridControl gridControl)
        {
            switch (objectEnum)
            {
            case ObjectEnum.Marka:
                var            brand = (DataRowView)obje;
                PRODUCT_BRANDS productBrand;
                switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    productBrand = new PRODUCT_BRANDS
                    {
                        BRAND_NAME = (string)brand["Marka"]
                    };
                    _repositoryBrand.Add(productBrand);
                    _uow.SaveChanges(); break;

                case ObjectIslem.Guncelle:
                    int id = (int)brand["Id"];
                    productBrand            = _repositoryBrand.Get(b => b.BRAND_ID == id);     // _dbproductContext.PRODUCT_BRANDS.FirstOrDefault(b => b.BRAND_ID ==id );
                    productBrand.BRAND_NAME = brand["Marka"].ToString();
                    _repositoryBrand.Update(productBrand);
                    _uow.SaveChanges();
                    break;

                case ObjectIslem.Listele:
                    List <MyGridView> objeList = (from pbs in _repositoryBrand.GetAll()
                                                  select new MyGridView()
                    {
                        Id = pbs.BRAND_ID,
                        Deger = pbs.BRAND_NAME,
                        kolonAdi = ObjectEnum.Marka.ToString()
                    }
                                                  ).ToList();
                    ds = new DataSet();
                    ds.Tables.Add(GetDataSource(objeList, ObjectEnum.Marka.ToString()));
                    gridControl.DataSource = ds.Tables[0];
                    break;
                }
                break;

            case ObjectEnum.Model:
                var model = (DataRowView)obje;
                PRODUCT_BRANDS_MODEL productBrandsModel; switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    productBrandsModel = new PRODUCT_BRANDS_MODEL {
                        BRAND_ID = iliskiliObjeId, MODEL_NAME = (string)model[objectEnum.ToString()]
                    };
                    _repositoryModel.Add(productBrandsModel);
                    _uow.SaveChanges(); break;

                case ObjectIslem.Guncelle:
                    int id = (int)model["Id"];
                    productBrandsModel            = _repositoryModel.Get(b => b.MODEL_ID == id);
                    productBrandsModel.MODEL_NAME = model[objectEnum.ToString()].ToString();
                    _repositoryModel.Update(productBrandsModel);
                    _uow.SaveChanges();
                    break;

                case ObjectIslem.Listele:
                    List <MyGridView> objeList = (from pbs in _repositoryModel.GetAllList() select new MyGridView()
                    {
                        // Id = pbs.BRAND_ID,
                        Id = pbs.MODEL_ID,
                        Deger = pbs.MODEL_NAME,
                        kolonAdi = objectEnum.ToString()
                    }
                                                  ).ToList();
                    ds = new DataSet();
                    ds.Tables.Add(GetDataSource(objeList, objectEnum.ToString()));
                    gridControl.DataSource = ds.Tables[0];
                    break;
                }
                break;

            case ObjectEnum.Birim:
                var        birim = (DataRowView)obje;
                SETUP_UNIT setupUnit;
                switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    setupUnit = new SETUP_UNIT {
                        UNIT = (string)birim[objectEnum.ToString()]
                    };
                    _repositoryUnit.Add(setupUnit);
                    _uow.SaveChanges();
                    break;

                case ObjectIslem.Guncelle:
                    int id = (int)birim["Id"];
                    setupUnit      = _repositoryUnit.Get(b => b.UNIT_ID == id);
                    setupUnit.UNIT = birim[objectEnum.ToString()].ToString();
                    _repositoryUnit.Update(setupUnit);
                    _uow.SaveChanges();
                    break;

                case ObjectIslem.Listele:
                    List <MyGridView> objeList = (from pbs in _repositoryUnit.GetAllList()
                                                  select new MyGridView()
                    {
                        Id = pbs.UNIT_ID,
                        Deger = pbs.UNIT,
                        kolonAdi = objectEnum.ToString()
                    }
                                                  ).ToList();
                    ds = new DataSet();
                    ds.Tables.Add(GetDataSource(objeList, objectEnum.ToString()));
                    gridControl.DataSource = ds.Tables[0];
                    break;
                }
                break;

            case ObjectEnum.UrunKategori:
                var         productCat_ = (DataRowView)obje;
                PRODUCT_CAT productCat;
                switch (objectIslem)
                {
                case ObjectIslem.Ekle:
                    productCat = new PRODUCT_CAT {
                        PRODUCT_CAT1 = (string)productCat_[objectEnum.ToString()], HIERARCHY = ""
                    };
                    _repositoryPCat.Add(productCat);
                    _uow.SaveChanges();
                    break;

                case ObjectIslem.Guncelle:
                    int id = (int)productCat_["Id"];
                    productCat = _repositoryPCat.Get(b => b.PRODUCT_CATID == id);
                    productCat.PRODUCT_CAT1 = productCat_[objectEnum.ToString()].ToString();
                    productCat.HIERARCHY    = "";
                    _repositoryPCat.Update(productCat);
                    _uow.SaveChanges();
                    break;

                case ObjectIslem.Listele:
                    List <MyGridView> objeList = (from pbs in _repositoryPCat.GetAllList()
                                                  select new MyGridView()
                    {
                        Id = pbs.PRODUCT_CATID,
                        Deger = pbs.PRODUCT_CAT1,
                        kolonAdi = objectEnum.ToString()
                    }
                                                  ).ToList();
                    ds = new DataSet();
                    ds.Tables.Add(GetDataSource(objeList, objectEnum.ToString()));
                    gridControl.DataSource = ds.Tables[0];
                    break;
                }
                break;
            }
        }