Пример #1
0
        private void Fill()
        {
            CWCarModelsLogic models = new CWCarModelsLogic(manager);
            CWCategoriesLogic categories = new CWCategoriesLogic(manager);

            CategoriesCB.DisplayMember = "Name";
            CategoriesCB.ValueMember = "ID";
            CategoriesCB.DataSource = categories.GetAll();

            if (mode == "edit")
            {
                CWCarModel model = models.Get(Convert.ToInt32(id));
                if (model != null)
                {
                    NameTB.Text = model.Name;
                    BrandImagePB.SizeMode = PictureBoxSizeMode.Zoom;

                    _image = Helpers.ImageOperations.ByteArrayToImage(model.Image);
                    image = model.Image;
                    BrandImagePB.Image = _image;
                    foreach (object category in CategoriesCB.Items)
                    {
                        if (((CWCategory)category).ID == model.CategoryID)
                        {
                            CategoriesCB.SelectedItem = category;
                        }
                    }
                }
            }
        }
Пример #2
0
        private void Fill()
        {
            CWCarModelsLogic  models     = new CWCarModelsLogic(manager);
            CWCategoriesLogic categories = new CWCategoriesLogic(manager);

            CategoriesCB.DisplayMember = "Name";
            CategoriesCB.ValueMember   = "ID";
            CategoriesCB.DataSource    = categories.GetAll();


            if (mode == "edit")
            {
                CWCarModel model = models.Get(Convert.ToInt32(id));
                if (model != null)
                {
                    NameTB.Text           = model.Name;
                    BrandImagePB.SizeMode = PictureBoxSizeMode.Zoom;

                    _image             = Helpers.ImageOperations.ByteArrayToImage(model.Image);
                    image              = model.Image;
                    BrandImagePB.Image = _image;
                    foreach (object category in CategoriesCB.Items)
                    {
                        if (((CWCategory)category).ID == model.CategoryID)
                        {
                            CategoriesCB.SelectedItem = category;
                        }
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// вказуємо модель автомобіля
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetModelBt_Click(object sender, EventArgs e)
        {
            Cars.ChooseModel form = new Cars.ChooseModel();
            form.WindowState = FormWindowState.Maximized;
            form.ShowDialog();
            modelId = form.SelectedModelID;
            brandId = form.SelectedBrandId;


            if (modelId != null)
            {
                CWCarModelsLogic modelsLogic = new CWCarModelsLogic(manager);
                CWCarModel       model       = modelsLogic.Get(Convert.ToInt32(modelId));
                CarModelPB.Image   = Helpers.ImageOperations.ByteArrayToImage(model.Image);
                CarModelNameL.Text = model.Name;

                foreach (object category in CarCategoriesCB.Items)
                {
                    if (((CWCategory)category).ID == model.CategoryID)
                    {
                        CarCategoriesCB.SelectedItem = category;
                    }
                }

                CarBrandNameL.Text = model.CWCarBrand.Name;
                CarBrandPB.Image   = Helpers.ImageOperations.ByteArrayToImage(model.CWCarBrand.Image);
            }
            else
            {
                if (brandId != null)
                {
                    CWCarBrandsLogic brandsLogic = new CWCarBrandsLogic(manager);
                    CWCarBrand       brand       = brandsLogic.Get(Convert.ToInt32(modelId));
                    CarBrandPB.Image   = Helpers.ImageOperations.ByteArrayToImage(brand.Image);
                    CarBrandNameL.Text = brand.Name;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// вказуємо модель автомобіля
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetModelBt_Click(object sender, EventArgs e)
        {
            Cars.ChooseModel form = new Cars.ChooseModel();
            form.WindowState = FormWindowState.Maximized;
            form.ShowDialog();
            modelId = form.SelectedModelID;
            brandId = form.SelectedBrandId;

            if (modelId != null)
            {
                CWCarModelsLogic modelsLogic = new CWCarModelsLogic(manager);
                CWCarModel model = modelsLogic.Get(Convert.ToInt32(modelId));
                CarModelPB.Image = Helpers.ImageOperations.ByteArrayToImage(model.Image);
                CarModelNameL.Text = model.Name;

                foreach (object category in CarCategoriesCB.Items)
                {
                    if (((CWCategory)category).ID == model.CategoryID)
                    {
                        CarCategoriesCB.SelectedItem = category;
                    }
                }

                CarBrandNameL.Text = model.CWCarBrand.Name;
                CarBrandPB.Image = Helpers.ImageOperations.ByteArrayToImage(model.CWCarBrand.Image);
            }
            else
            {
                if (brandId != null)
                {
                    CWCarBrandsLogic brandsLogic = new CWCarBrandsLogic(manager);
                    CWCarBrand brand = brandsLogic.Get(Convert.ToInt32(modelId));
                    CarBrandPB.Image = Helpers.ImageOperations.ByteArrayToImage(brand.Image);
                    CarBrandNameL.Text = brand.Name;
                }
            }
        }