Files
DugunSalonu/FrmAddKullanici.cs

58 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DugunSalonu.Models;
using System.Threading.Tasks;
namespace DugunSalonu
{
public partial class FrmAddKullanici : Form
{
public FrmAddKullanici()
{
InitializeComponent();
}
private async void btnEkle_Click(object sender, EventArgs e)
{
if (txtParola.Text != txtParolatekrar.Text)
{
MessageBox.Show("Parolalar eşleşmiyor.", "Hata");
return;
}
using (dugunsalonuContext db = new dugunsalonuContext())
{
await db.kullanici.AddAsync(new Kullanici
{
adi = txtAdi.Text,
soyadi = txtSoyadi.Text,
kullaniciadi = txtKullaniciAdi.Text,
parola = txtParola.Text,
aktif = true,
admin = false,
ceptel = txtCeptel.Text,
eposta = txtEposta.Text
});
await db.SaveChangesAsync();
FormTemizle();
MessageBox.Show("İşlem başarılı", "Ekleme");
}
}
private void btnVazgec_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void FormTemizle()
{
foreach (TextBox item in this.Controls)
{
if (item is TextBox)
{
item.Clear();
}
}
}
}
}