示例#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 DeleteSB_Click(object sender, EventArgs e)
 {
     CWCarModelsLogic models = new CWCarModelsLogic(manager);
     models.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value));
     manager.Save();
     Fill();
 }
示例#3
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            CWCarModelsLogic models = new CWCarModelsLogic(manager);

            if (mode == "new")
            {
                image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName);

                models.Create(NameTB.Text, Convert.ToInt32(brandId), image, Convert.ToInt32(CategoriesCB.SelectedValue));
            }
            if (mode == "edit")
            {
                if (_image != null)
                {
                    image = Helpers.ImageOperations.ImageToByteArray(_image);
                }
                else
                {
                    image = null;
                }
                models.Update(Convert.ToInt32(id), NameTB.Text, image, Convert.ToInt32(CategoriesCB.SelectedValue));
            }
            manager.Save();

            this.Close();
        }
示例#4
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;
                        }
                    }
                }
            }
        }
示例#5
0
        private void DeleteSB_Click(object sender, EventArgs e)
        {
            CWCarModelsLogic models = new CWCarModelsLogic(manager);

            models.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value));
            manager.Save();
            Fill();
        }
示例#6
0
 private void Fill()
 {
     CWCarModelsLogic models = new CWCarModelsLogic(manager);
     DataGV.AutoGenerateColumns = false;
     if(brandId != null)
         DataGV.DataSource = models.GetAll(Convert.ToInt32(brandId));
     else
         DataGV.DataSource = models.GetAll();
     DataGV.Update();
 }
示例#7
0
        private void Fill()
        {
            CWCarModelsLogic models = new CWCarModelsLogic(manager);

            DataGV.AutoGenerateColumns = false;
            if (brandId != null)
            {
                DataGV.DataSource = models.GetAll(Convert.ToInt32(brandId));
            }
            else
            {
                DataGV.DataSource = models.GetAll();
            }
            DataGV.Update();
        }
示例#8
0
        private void FillModels()
        {
            CWCarModelsLogic models = new CWCarModelsLogic(manager);

            ModelsDataGV.AutoGenerateColumns = false;
            int?brandId = null;

            if (BrandsDataGV.SelectedRows.Count > 0)
            {
                brandId = Convert.ToInt32(BrandsDataGV.CurrentRow.Cells["BrandID"].Value);
            }
            if (brandId != null)
            {
                ModelsDataGV.DataSource = models.GetAll(Convert.ToInt32(brandId));
            }
            else
            {
                ModelsDataGV.DataSource = models.GetAll();
            }
            ModelsDataGV.Update();
        }
示例#9
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;
                }
            }
        }
示例#10
0
文件: CarData.cs 项目: rymarrv/Compas
        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
文件: CarData.cs 项目: zep2zep/Compas
        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")
            {
            }
        }
示例#12
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;
                }
            }
        }
示例#13
0
文件: CarData.cs 项目: rymarrv/Compas
 private void FillModels()
 {
     CWCarModelsLogic models = new CWCarModelsLogic(manager);
     ModelsDataGV.AutoGenerateColumns = false;
     int? brandId = null;
     if (BrandsDataGV.SelectedRows.Count > 0)
     {
         brandId = Convert.ToInt32(BrandsDataGV.CurrentRow.Cells["BrandID"].Value);
     }
     if (brandId != null)
         ModelsDataGV.DataSource = models.GetAll(Convert.ToInt32(brandId));
     else
         ModelsDataGV.DataSource = models.GetAll();
     ModelsDataGV.Update();
 }
示例#14
0
        private void SaveBt_Click(object sender, EventArgs e)
        {
            CWCarModelsLogic models = new CWCarModelsLogic(manager);

            if (mode == "new")
            {
                image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName);

                models.Create(NameTB.Text, Convert.ToInt32(brandId), image, Convert.ToInt32(CategoriesCB.SelectedValue));
            }
            if (mode == "edit")
            {
                if (_image != null)
                    image = Helpers.ImageOperations.ImageToByteArray(_image);
                else
                    image = null;
                models.Update(Convert.ToInt32(id), NameTB.Text, image, Convert.ToInt32(CategoriesCB.SelectedValue));
            }
            manager.Save();

            this.Close();
        }