Пример #1
0
 private void DeleteSB_Click(object sender, EventArgs e)
 {
     CWCarBrandsLogic brands = new CWCarBrandsLogic(manager);
     brands.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value));
     manager.Save();
     Fill();
 }
Пример #2
0
 private void Fill()
 {
     CWCarBrandsLogic brands = new CWCarBrandsLogic(manager);
     DataGV.AutoGenerateColumns = false;
     DataGV.DataSource = brands.GetAll();
     DataGV.Update();
 }
Пример #3
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            CWCarBrandsLogic units = new CWCarBrandsLogic(manager);


            if (mode == "new")
            {
                if (openFileDialog1.CheckPathExists == true)
                {
                    image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName);
                }
                units.Create(NameTB.Text, image);
            }
            if (mode == "edit")
            {
                if (_image != null)
                {
                    image = Helpers.ImageOperations.ImageToByteArray(_image);
                }
                else
                {
                    image = null;
                }
                units.Update(Convert.ToInt32(id), NameTB.Text, image);
            }
            manager.Save();

            this.Close();
        }
Пример #4
0
        private void DeleteSB_Click(object sender, EventArgs e)
        {
            CWCarBrandsLogic brands = new CWCarBrandsLogic(manager);

            brands.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value));
            manager.Save();
            Fill();
        }
Пример #5
0
        private void Fill()
        {
            CWCarBrandsLogic brands = new CWCarBrandsLogic(manager);

            DataGV.AutoGenerateColumns = false;
            DataGV.DataSource          = brands.GetAll();
            DataGV.Update();
        }
Пример #6
0
        private void Fill()
        {
            CWCarBrandsLogic units = new CWCarBrandsLogic(manager);

            if (mode == "edit")
            {
                CWCarBrand unit = units.Get(Convert.ToInt32(id));
                if (unit != null)
                {
                    NameTB.Text = unit.Name;
                    BrandImagePB.SizeMode = PictureBoxSizeMode.Zoom;
                    _image =  Helpers.ImageOperations.ByteArrayToImage(unit.Image);
                    image = unit.Image;
                    BrandImagePB.Image = _image;
                }
            }
        }
Пример #7
0
        private void Fill()
        {
            CWCarBrandsLogic units = new CWCarBrandsLogic(manager);

            if (mode == "edit")
            {
                CWCarBrand unit = units.Get(Convert.ToInt32(id));
                if (unit != null)
                {
                    NameTB.Text           = unit.Name;
                    BrandImagePB.SizeMode = PictureBoxSizeMode.Zoom;
                    _image             = Helpers.ImageOperations.ByteArrayToImage(unit.Image);
                    image              = unit.Image;
                    BrandImagePB.Image = _image;
                }
            }
        }
Пример #8
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;
                }
            }
        }
Пример #9
0
        public CarData(string _mode, int? _id)
        {
            InitializeComponent();
            manager = new ContextManager();
            mode = _mode;

            CWCarBrandsLogic carBrandsLogic = new CWCarBrandsLogic(manager);
            int i = 0;

            foreach (CWCarBrand brand in carBrandsLogic.GetAll())
            {
                //BrandsICB.Properties.Items.Add(new DevExpress.XtraEditors.Controls.ImageComboBoxItem(brand, i));
            }

            CWCarModelsLogic carModelsLogic = new CWCarModelsLogic(manager);
            //ModelsLUE.Properties.DataSource = carModelsLogic.GetAll();

            id = _id;
            Fill();
            if (mode == "edit")
            {

            }
        }
Пример #10
0
        public CarData(string _mode, int?_id)
        {
            InitializeComponent();
            manager = new ContextManager();
            mode    = _mode;

            CWCarBrandsLogic carBrandsLogic = new CWCarBrandsLogic(manager);
            int i = 0;

            foreach (CWCarBrand brand in carBrandsLogic.GetAll())
            {
                //BrandsICB.Properties.Items.Add(new DevExpress.XtraEditors.Controls.ImageComboBoxItem(brand, i));
            }

            CWCarModelsLogic carModelsLogic = new CWCarModelsLogic(manager);

            //ModelsLUE.Properties.DataSource = carModelsLogic.GetAll();

            id = _id;
            Fill();
            if (mode == "edit")
            {
            }
        }
Пример #11
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;
                }
            }
        }
Пример #12
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            CWCarBrandsLogic units = new CWCarBrandsLogic(manager);

            if (mode == "new")
            {
                if (openFileDialog1.CheckPathExists == true)
                    image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName);
                units.Create(NameTB.Text, image);
            }
            if (mode == "edit")
            {
                if (_image != null)
                    image = Helpers.ImageOperations.ImageToByteArray(_image);
                else
                    image = null;
                units.Update(Convert.ToInt32(id), NameTB.Text, image);
            }
            manager.Save();

            this.Close();
        }