private void Button2_Click(object sender, EventArgs e) { try { Customer customerToDelete = new Customer { CustomerID = Convert.ToInt32(listView1.SelectedItems[0].SubItems[1].Text), Name = listView1.SelectedItems[0].SubItems[2].Text, Surname = listView1.SelectedItems[0].SubItems[3].Text, Phone = listView1.SelectedItems[0].SubItems[4].Text, Address = listView1.SelectedItems[0].SubItems[5].Text }; var sorgu = DalCustomer.CUD(customerToDelete, System.Data.Entity.EntityState.Deleted); if (sorgu) { GuncelleMusteriler(); MessageBox.Show("Müşteri silindi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("Müşteri seçilmedi.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Button3_Click(object sender, EventArgs e) { try { var anyEmptyArea = EmptyTextBoxControl(groupBox3); if (anyEmptyArea) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Customer newCustomer = new Customer { Name = textBox1.Text, Surname = textBox2.Text, Phone = textBox3.Text, Address = textBox4.Text }; var sorgu = DalCustomer.CUD(newCustomer, System.Data.Entity.EntityState.Added); if (sorgu == true) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); GuncelleMusteriler(); MessageBox.Show("Yeni müşteri eklendi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Müşteri ekleme başarısız.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Button4_Click(object sender, EventArgs e) { try { var anyEmptyArea = EmptyTextBoxControl(groupBox4); if (anyEmptyArea) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Customer customerToUpdate = new Customer { CustomerID = Convert.ToInt32(textBox27.Text), Name = textBox8.Text, Surname = textBox7.Text, Phone = textBox6.Text, Address = textBox5.Text }; var sorgu = DalCustomer.CUD(customerToUpdate, System.Data.Entity.EntityState.Modified); if (sorgu) { textBox5.Clear(); textBox6.Clear(); textBox7.Clear(); textBox8.Clear(); GuncelleMusteriler(); MessageBox.Show("Müşteri bilgileri güncellendi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }