예제 #1
0
        public DriverInfoForm(driver d)
        {
            InitializeComponent();
            driverFamilyName.Text = d.family_name;
            driverName.Text       = d.name;
            driverCountry.Text    = d.country;
            driverBirth.Text      = d.birth.ToShortDateString();
            driverPodiums.Text    = d.podiums.ToString();
            driverExperience.Text = d.experience.ToString();
            driverTrophies.Text   = d.trophies.ToString();
            driverNumber.Text     = d.number.ToString();
            string path = System.IO.Directory.GetCurrentDirectory();

            try
            {
                driverPhotoPictureBox.Image = Image.FromFile("../../Photos/" + driverFamilyName.Text + ".jpg");
                //driverPhotoPictureBox.ImageLocation = "./Photos/" + driverFamilyName.Text + ".jpg";
                driverPhotoPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            catch (Exception)
            {
                //MessageBox.Show("No Photo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            this.Text = "Driver --- " + driverName.Text + " " + driverFamilyName.Text;
        }
예제 #2
0
 public DriverEditForm(driver nd)
 {
     InitializeComponent();
     d = nd;
     familyNameTextBox.Text = d.family_name;
     nameTextBox.Text       = d.name;
     countryTextBox.Text    = d.country;
     birthTextBox.Text      = Convert.ToString(d.birth);
     podiumsTextBox.Text    = Convert.ToString(d.podiums);
     experienceTextBox.Text = Convert.ToString(d.experience);
     trophiesTextBox.Text   = Convert.ToString(d.trophies);
     numberTextBox.Text     = Convert.ToString(d.number);
     pointsTextBox.Text     = Convert.ToString(d.points);
 }
예제 #3
0
        private void driversDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //23.24
            int id = Convert.ToInt32(driversDataGridView.CurrentRow.Cells[0].Value);

            if (e.ColumnIndex == 23)
            {
                // Info
                driver locd = context.drivers.Find(id);
                using (DriverInfoForm frm = new DriverInfoForm(locd))
                {
                    frm.ShowDialog();
                }
            }
            if (e.ColumnIndex == 24)
            {
                if (loggedUser == "Admin")
                {
                    //Edit
                    driver locd = context.drivers.Find(id);
                    using (DriverEditForm frm = new DriverEditForm(locd))
                    {
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            if (dbm.EditDriver(id, frm.familyNameTextBox.Text, frm.nameTextBox.Text, frm.countryTextBox.Text, Convert.ToDateTime(frm.birthTextBox.Text), Convert.ToInt32(frm.podiumsTextBox.Text), Convert.ToInt32(frm.experienceTextBox.Text), Convert.ToInt32(frm.trophiesTextBox.Text), Convert.ToInt32(frm.numberTextBox.Text), Convert.ToInt32(frm.pointsTextBox.Text)))
                            {
                                MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            driversDataGridView.DataSource = context.drivers.ToList();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Access Denied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (e.ColumnIndex == 25)
            {
                if (loggedUser == "Admin")
                {
                    //Delete
                    if (dbm.DeleteDriver(id))
                    {
                        MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    driversDataGridView.DataSource = context.drivers.ToList();
                }
                else
                {
                    MessageBox.Show("Access Denied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }