private void EkleButton_Click(object sender, EventArgs e) { DialogResult Cevap = MessageBox.Show("Yeni stok gurubunu eklemek istediğinize emin misiniz?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Cevap == DialogResult.Yes) { if (!(StokGrupVarmi(StokGrupTextBox.Text))) { komut = new SqlCommand(); komut.CommandText = "insert into stok_gruplari (stok_grup) values(@stok_grup)"; komut.Connection = baglanti; komut.Parameters.AddWithValue("@stok_grup", StokGrupTextBox.Text.ToUpper()); if (baglanti.State != ConnectionState.Open) { baglanti.Open(); } komut.ExecuteNonQuery(); if (baglanti.State == ConnectionState.Open) { baglanti.Close(); } GruplarıGetir(); } else { MessageBox.Show("Bu stok gurubu zaten mevcut. Başka bir grup ismi belirleyin.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information); } StokGrupTextBox.Clear(); } }
private void CikarButton_Click(object sender, EventArgs e) { DialogResult Cevap = MessageBox.Show("Yeni stok gurubunu silmek istediğinize emin misiniz?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Cevap == DialogResult.Yes) { komut = new SqlCommand(); komut.CommandText = "delete from stok_gruplari where stok_grup=@stok_grup"; komut.Connection = baglanti; komut.Parameters.AddWithValue("@stok_grup", StokGrupListBox.SelectedItem.ToString()); if (baglanti.State != ConnectionState.Open) { baglanti.Open(); } komut.ExecuteNonQuery(); if (baglanti.State == ConnectionState.Open) { baglanti.Close(); } StokGrupTextBox.Clear(); StokGrupListBox.Items.RemoveAt(StokGrupListBox.SelectedIndex); } }
private void Stok_gruplari_Load(object sender, EventArgs e) { GruplarıGetir(); StokGrupTextBox.Focus(); }