Beispiel #1
0
        internal void Save(UCAddAutomobil uCAddAutomobil)
        {
            if (!UserControlHelpers.RegistrationValidation(uCAddAutomobil.TxtRegistracija, uCAddAutomobil.LblRegistracija)
                | !UserControlHelpers.VINNumberValidation(uCAddAutomobil.TxtBrojSasije, uCAddAutomobil.LblBrojSasije)
                | !UserControlHelpers.ComboBoxValidation(uCAddAutomobil.CbMarka, uCAddAutomobil.LblMarka)
                | !UserControlHelpers.ComboBoxValidation(uCAddAutomobil.CbModel, uCAddAutomobil.LblModel)
                )
            {
                return;
            }
            try
            {
                string    k     = CommaConversion(uCAddAutomobil.TxtCenaPoDanu.Text);
                Model     model = (Model)uCAddAutomobil.CbModel.SelectedItem;
                Automobil a     = new Automobil
                {
                    /*BrojSasije = uCAddAutomobil.TxtBrojSasije.Text,
                     * Registracija = uCAddAutomobil.TxtRegistracija.Text,
                     * Model = (Model)uCAddAutomobil.CbModel.SelectedItem,
                     * GodinaProizvodnje = (int)uCAddAutomobil.CbGodiste.SelectedItem,*/
                    WhereCondition = "a.BrojSasije=",
                    WhereValue     = uCAddAutomobil.TxtBrojSasije.Text,
                    InsertValues   = $"'{uCAddAutomobil.TxtBrojSasije.Text}','{uCAddAutomobil.TxtRegistracija.Text}',{(int)uCAddAutomobil.CbGodiste.SelectedItem},{k},{model.Id}"
                };

                /*List<Automobil> automobilBrSasije;
                 * if (Communication.Communication.Instance.SearchAutomobilBrSasije(a))
                 * {
                 *  Communication.Communication.Instance.SaveAutomobil(a);
                 *  System.Windows.Forms.MessageBox.Show("Automobil je uspesno sacuvan");
                 *  ResetForm(uCAddAutomobil);
                 * }
                 * else
                 * {
                 *  automobilBrSasije = Communication.Communication.Instance.SearchAutomobil(a);
                 *  System.Windows.Forms.MessageBox.Show("Vec postoji automobil sa ovim brojem sasije");
                 *  return;
                 * }*/
                Communication.Communication.Instance.SaveAutomobil(a);
                System.Windows.Forms.MessageBox.Show("Automobil je uspesno sacuvan");
                ResetForm(uCAddAutomobil);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }