-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (43 loc) · 1.99 KB
/
Copy pathProgram.cs
File metadata and controls
49 lines (43 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Windows.Forms;
using LibraryManagementSystem.Database;
using LibraryManagementSystem.Forms;
namespace LibraryManagementSystem
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Initialize database
try
{
DatabaseHelper.InitializeDatabase();
}
catch (Exception ex)
{
MessageBox.Show($"Veritabanı başlatılırken hata oluştu: {ex.Message}", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Start with login form
Application.Run(new LoginForm());
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
MessageBox.Show($"Sistemde beklenmeyen bir hata oluştu.\nDetay: {e.Exception.Message}\nUygulama arka planda durumu kurtarmaya çalışarak devam edecek.", "Güvenlik Uyarısı (Crash Handler)", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception ex = e.ExceptionObject as Exception;
string message = ex != null ? ex.Message : "Bilinmeyen kritik hata";
MessageBox.Show($"Çok kritik bir hata oluştu ve uygulamanın çökmesi engellendi.\nDetay: {message}\nLütfen uygulamayı yeniden başlatın.", "Kritik Sistem Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}