コード例 #1
0
 public static void Update(ModelCar modelCar)
 {
     if (modelCar.Id == 0)
     {
         repository.ModelCars.Add(modelCar);
     }
     repository.SaveChanges();
 }
コード例 #2
0
        private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                ModelCar modelCar = dataGridView1.SelectedRows[0].DataBoundItem as ModelCar;

                Controller.Remove(modelCar);
                UpdateData();
            }
        }
コード例 #3
0
        public NewModelForm(ModelCar modelCar = null)
        {
            InitializeComponent();

            if (modelCar != null)
            {
                txtBxName.Text = modelCar.Name;
                this.modelCar  = modelCar;
            }
        }
コード例 #4
0
        private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                ModelCar modelCar = dataGridView1.SelectedRows[0].DataBoundItem as ModelCar;

                NewModelForm form = new NewModelForm(modelCar);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    UpdateData();
                }
            }
        }
コード例 #5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtBxName.Text == "")
            {
                MessageBox.Show("Укажите название модели");
                return;
            }

            if (modelCar == null)
            {
                modelCar = new ModelCar();
            }

            modelCar.Name = txtBxName.Text;
            Controller.Update(modelCar);

            DialogResult = DialogResult.OK;
        }
コード例 #6
0
 public static void Remove(ModelCar modelCar)
 {
     repository.ModelCars.Remove(modelCar);
     repository.SaveChanges();
 }