コード例 #1
0
ファイル: CreateColumn.cs プロジェクト: IT-SSM/PrvaFaza
        private void button1_Click(object sender, EventArgs e)
        {
            string type = "";

            if (textBoxKolona.Text == "")
            {
                MessageBox.Show("Morate uneti naziv kolone!");
                return;
            }

            if (comboBoxTipPolja.SelectedItem.ToString() == "Character" && textBoxAtribut.Text == "")
            {
                MessageBox.Show("Popunite duzinu karaktera!");
                return;
            }
            else
            {
                if (PocetnaForma.database == "Oracle")
                {
                    type = "varchar2(" + textBoxAtribut.Text + ")";
                }

                if (PocetnaForma.database == "MSSQL")
                {
                    type = "varchar(" + textBoxAtribut.Text + ")";
                }
            }

            try
            {
                if (kki.proveraDaLiPostojiKolonaUTabeli(comboBoxTabele, textBoxKolona) == false)
                {
                    if (kki.insertIntoColList(comboBoxTabele, comboBoxTipPolja, textBoxKolona, textBoxAtribut.Text) == 1 && kki.kreirajKolonu(comboBoxTabele, textBoxKolona, comboBoxTipPolja, type) == -1)
                    {
                        MessageBox.Show("Kolona je uspesno dodata!");
                    }
                }
                else
                {
                    MessageBox.Show("Kolona vec postoji u tabeli!");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Greska prilikom dodavanja kolone! " + ex.Message);
                throw;
            }
        }