private void Delete_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand(" DELETE FROM Prekes WHERE PrekesID = " + PrekID, con);

            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            Prekes.SelectedItem = null;
            PrekID = -1;
            GaminText.Clear(); PavText.Clear(); ModText.Clear(); TrumAPText.Clear(); KainaText.Clear(); Aprasymas.Items.Clear();
            FillData();
        }
 private void NewPrek_Click(object sender, EventArgs e)
 {
     if (GaminText.Text == "" || PavText.Text == "" || ModText.Text == "" || TrumAPText.Text == "" || KainaText.Text == "")
     {
         MessageBox.Show("Fill all the colums");
     }
     else if (Prekes.SelectedItem == null)
     {
         SqlCommand cmd = new SqlCommand("INSERT INTO Prekes (Gamintojas, Pavadinimas, Modelis, Aprasymas, Kaina) Values (@Gamintojas, @Pavadinimas, @Modelis, @Aprasymas, @Kaina) ", con);
         cmd.Parameters.AddWithValue("@Gamintojas", GaminText.Text);
         cmd.Parameters.AddWithValue("@Pavadinimas", PavText.Text);
         cmd.Parameters.AddWithValue("@Modelis", ModText.Text);
         cmd.Parameters.AddWithValue("@Aprasymas", TrumAPText.Text);
         cmd.Parameters.AddWithValue("@Kaina", KainaText.Text);
         con.Open();
         SqlDataAdapter adapt = new SqlDataAdapter(cmd);
         DataSet        ds    = new DataSet();
         adapt.Fill(ds);
         con.Close();
         MessageBox.Show("Preke Irasyta i sistema");
         GaminText.Clear(); PavText.Clear(); ModText.Clear(); TrumAPText.Clear(); KainaText.Clear();
     }
     else
     {
         SqlCommand cmd = new SqlCommand("Update Prekes SET Gamintojas = @Gamintojas, Pavadinimas = @Pavadinimas, Modelis = Modelis, Aprasymas = @Aprasymas, Kaina = @Kaina where PrekesID =" + PrekID, con);
         cmd.Parameters.AddWithValue("@Gamintojas", GaminText.Text);
         cmd.Parameters.AddWithValue("@Pavadinimas", PavText.Text);
         cmd.Parameters.AddWithValue("@Modelis", ModText.Text);
         cmd.Parameters.AddWithValue("@Aprasymas", TrumAPText.Text);
         cmd.Parameters.AddWithValue("@Kaina", KainaText.Text);
         con.Open();
         SqlDataAdapter adapt = new SqlDataAdapter(cmd);
         DataSet        ds    = new DataSet();
         adapt.Fill(ds);
         con.Close();
         GaminText.Clear(); PavText.Clear(); ModText.Clear(); TrumAPText.Clear(); KainaText.Clear();
         MessageBox.Show("Preke sekmingai suredaguota");
         PrekID = -1;
     }
     FillData();
 }
 private void ClearSelect_Click(object sender, EventArgs e)
 {
     Prekes.SelectedItem = null;
     PrekID = -1;
     GaminText.Clear(); PavText.Clear(); ModText.Clear(); TrumAPText.Clear(); KainaText.Clear();
 }