Exemplo n.º 1
0
        void ObjeSec(ModelObjects.ObjectEnum objectEnum)
        {
            DialogResult dialogResult;
            FrmObjeList  objeSec;

            switch (objectEnum)
            {
            case ModelObjects.ObjectEnum.Marka:
                objeSec      = new FrmObjeList(ModelObjects.ObjectEnum.Marka, 0);
                dialogResult = objeSec.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    _brand            = (PRODUCT_BRANDS)objeSec.secilenObje;
                    btnEditMarka.Text = _brand.BRAND_NAME;
                }
                break;

            case ModelObjects.ObjectEnum.Model:
                objeSec      = new FrmObjeList(ModelObjects.ObjectEnum.Model, 0);
                dialogResult = objeSec.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    _model            = (PRODUCT_BRANDS_MODEL)objeSec.secilenObje;
                    btnEditModel.Text = _model.MODEL_NAME;
                }
                break;

            case ModelObjects.ObjectEnum.Birim:
                objeSec      = new FrmObjeList(ModelObjects.ObjectEnum.Birim, 0);
                dialogResult = objeSec.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    _birim            = (SETUP_UNIT)objeSec.secilenObje;
                    btnEditBirim.Text = _birim.UNIT;
                }
                break;

            case ModelObjects.ObjectEnum.UrunKategori:
                objeSec      = new FrmObjeList(ModelObjects.ObjectEnum.UrunKategori, 0);
                dialogResult = objeSec.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    _urunKategori        = (PRODUCT_CAT)objeSec.secilenObje;
                    btnEditKategori.Text = _urunKategori.PRODUCT_CAT1;
                }
                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;
            }
        }