Esempio n. 1
0
        private void PreviousCar(object sender, EventArgs e)
        {
            Auto newAuto = registerHandler.GetPreviousCar(currentID);

            Malli_cBox.Items.Clear();
            ID_Label.Text = "ID: " + newAuto.Id;
            currentID     = newAuto.Id;

            //Textfield values
            hinta.Text = newAuto.Hinta.ToString();
            try {
                paivamaara_Picker.Value = new DateTime(newAuto.Rekisteri_paivamaara.Year, newAuto.Rekisteri_paivamaara.Month, newAuto.Rekisteri_paivamaara.Day);
            }
            catch
            { MessageBox.Show("Couldn't pull data from DB"); }

            tilavuus.Text      = newAuto.Moottorin_tilavuus.ToString();
            mittarilukema.Text = newAuto.Mittarilukema.ToString();

            Merkki_cBox.SelectedIndex = newAuto.AutonMerkkiID - 1;


            AutonMalli[] models = registerHandler.getAutoModels(newAuto.AutonMerkkiID).ToArray();
            foreach (AutonMalli malli in models)
            {
                Malli_cBox.Items.Add(malli);
            }
            Malli_cBox.DisplayMember = "MalliNimi";

            foreach (AutonMalli malli in models)
            {
                if (malli.Id == newAuto.AutonMalliID)
                {
                    Malli_cBox.SelectedItem = malli;
                    break;
                }
            }
            Malli_cBox.SelectedValue = newAuto.AutonMalliID.ToString();

            fuel_cBox.SelectedIndex  = newAuto.PolttoaineID - 1;
            color_cBox.SelectedIndex = newAuto.VaritID - 1;
        }