コード例 #1
0
        public EngineOperation(DataFormDTO dto, FormUsage usage, ViewEngineCar engineCar)
        {
            this.dto    = dto;
            this.usage  = usage;
            this.engine = engineCar;

            InitializeComponent();
        }
コード例 #2
0
ファイル: EngineForm.cs プロジェクト: alukart32/carDealerApp
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["engineIdDataGridViewTextBoxColumn"].Value);

            ViewEngineCar eng = dto.db.ViewEngineCars.SingleOrDefault(o => o.engineId == id);

            // update
            if (e.ColumnIndex == 5)
            {
                // в след. форму
                DataFormDTO d = new DataFormDTO(this, dto.mainForm, dto.db,
                                                dto.userIdentity, dto.userData);

                EngineOperation form = new EngineOperation(d, FormUsage.Update, eng);
                form.Show();
            }

            // delete
            if (e.ColumnIndex == 6)
            {
                // Запрашиваем подтверждение
                string message = "Точно хотите удалить?";
                string caption = "Y/n";
                var    result  = MessageBox.Show(message, caption,
                                                 MessageBoxButtons.YesNo,
                                                 MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    // deleting
                    if (crud.delete(eng))
                    {
                        MessageBox.Show("Трансмиссия удалена!");
                        resetData();
                    }
                    else
                    {
                        MessageBox.Show("Что-то не так!!!");
                    }
                }
            }
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            // validation

            //if (!companyPicked)
            //{


            //    MessageBox.Show("Не выбран производитель!!!");
            //    return;
            //}

            //if (!typePicked)
            //{
            //    MessageBox.Show("Не выбран тип!!!");
            //    return;
            //}

            if (!this.eng.IsMatch(engineStr))
            {
                if (!engineStr.Contains(" "))
                {
                    MessageBox.Show("Неправильное наименование двигателя!!!");
                    return;
                }
            }

            if (!this.eng.IsMatch(type))
            {
                if (!type.Contains(" "))
                {
                    MessageBox.Show("Неправильное наименование типа!!!");
                    return;
                }
            }

            if (!num.IsMatch(power))
            {
                MessageBox.Show("Неправильная мощность!!!");
                return;
            }

            int powers = Int32.Parse(power);

            if (powers <= 0)
            {
                MessageBox.Show("Неправильная мощность!!!");
                return;
            }

            if (!num.IsMatch(price))
            {
                MessageBox.Show("Неправильная цена!!!");
                return;
            }

            decimal prices = Decimal.Parse(price);

            if (prices <= 0)
            {
                MessageBox.Show("Неправильная wtyf!!!");
                return;
            }

            ViewEngineCar eng = new ViewEngineCar();

            eng.company     = company;
            eng.engine      = engineStr;
            eng.enginePrice = prices;
            eng.engineType  = type;
            eng.power       = powers;

            eng.engineTypeId   = engineType.engineTypeId;
            eng.manufacturerId = manufacturer.manufacturerId;

            if (usage == FormUsage.Update)
            {
                eng.engineId = engine.engineId;
                if (crud.update(eng))
                {
                    MessageBox.Show("Двигатель обновлен!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Что-то не так!!!");
                }

                return;
            }

            if (!companyPicked)
            {
                MessageBox.Show("Не выбран производитель!!!");
                return;
            }

            if (!typePicked)
            {
                MessageBox.Show("Не выбран тип!!!");
                return;
            }

            if (crud.create(eng))
            {
                MessageBox.Show("Трансмиссия добавлена!");
                this.Close();
            }
            else
            {
                MessageBox.Show("Что-то не так!!!");
            }
        }