Files
DugunSalonu/FrmLogin.cs
2025-08-11 11:51:35 +03:00

84 lines
2.4 KiB
C#

using DugunSalonu.Models;
using Microsoft.EntityFrameworkCore;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Buffers;
using System.Resources;
using DugunSalonu.Properties;
namespace DugunSalonu
{
public partial class FrmLogin : Form
{
public FrmLogin()
{
InitializeComponent();
}
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool ReleaseCapture();
private void FrmLogin_Load(object sender, EventArgs e)
{
}
private void btnVazgec_Click(object sender, EventArgs e)
{
Application.Exit();
}
private async void btnGiris_Click(object sender, EventArgs e)
{
try
{
using (dugunsalonuContext db = new dugunsalonuContext())
{
var user = await db.kullanici.Where(k => k.kullaniciadi == txtKullanici.Text && k.aktif == true && k.parola == txtSifre.Text).FirstOrDefaultAsync();
if (user != null)
{
btnGiris.BackgroundImage = Resources.loginAcik;
Task.Delay(2000).Wait();
FrmAddKullanici f1 = new FrmAddKullanici();
f1.Show();
this.Hide();
}
else { MessageBox.Show("Hatalý kullanýcý bilgileri.", "Hata"); }
//Kullanici girisKullanicisi = await db.Kullanici.Where(k => k.KullaniciAdi == txtKullanici.Text && k.Parola == txtSifre.Text).FirstOrDefaultAsync();
}
}
catch (Exception)
{
throw;
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void pnlTop_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
}
}