示例#1
0
 private void carsAddBtn_Click(object sender, EventArgs e)
 {
     if (loggedUser == "Admin")
     {
         using (CarEdit frm = new CarEdit())
         {
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 if (dbm.CreateCar(Convert.ToInt32(frm.enginePowerNumericUpDown.Value), Convert.ToDouble(frm.fuelEffNumericUpDown.Value), Convert.ToInt32(frm.resourseNumericUpDown.Value), Convert.ToDouble(frm.weightNumericUpDown.Value)) != null)
                 {
                     MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 carsDataGridView.DataSource = context.cars.ToList();
             }
         }
     }
     else
     {
         MessageBox.Show("Access Denied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
文件: TeamInfo.cs 项目: MrNKP/DADBF1
 private void car1Btn_Click(object sender, EventArgs e)
 {
     using (CarEdit frm = new CarEdit(loct.car))
     {
         frm.ShowDialog();
     }
 }
示例#3
0
        private void carsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //7.8
            int id = Convert.ToInt32(carsDataGridView.CurrentRow.Cells[0].Value);

            if (e.ColumnIndex == 7)
            {
                //Edit
                if (loggedUser == "Admin")
                {
                    car c = context.cars.Find(id);
                    using (CarEdit frm = new CarEdit(c))
                    {
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            if (dbm.EditCar(id, Convert.ToInt32(frm.enginePowerNumericUpDown.Value), Convert.ToDouble(frm.fuelEffNumericUpDown.Value), Convert.ToInt32(frm.resourseNumericUpDown.Value), Convert.ToDouble(frm.weightNumericUpDown.Value)))
                            {
                                MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            carsDataGridView.DataSource = context.cars.ToList();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Access Denied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (e.ColumnIndex == 8)
            {
                if (loggedUser == "Admin")
                {
                    //Delete
                    if (dbm.DeleteDriver(id))
                    {
                        MessageBox.Show("Deleted", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    carsDataGridView.DataSource = context.cars.ToList();
                }
                else
                {
                    MessageBox.Show("Access Denied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }