-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathProgram.cs
70 lines (66 loc) · 1.99 KB
/
Program.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Microsoft.EntityFrameworkCore;
using ProFak.DB;
using ProFak.UI;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProFak
{
public static class Program
{
[STAThread]
public static void Main(string[] args)
{
try
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("pl-PL");
if (!DB.Baza.Przygotuj())
{
using var pierwszyStart = new UI.PierwszyStartBaza();
if (pierwszyStart.ShowDialog() != DialogResult.OK) return;
}
if (args.Length > 0)
{
if (args[0] == "xsd") Wydruki.GeneratorXSD.Utworz();
if (args[0] == "sql")
{
using var kontekst = new UI.Kontekst();
using var dialog = new UI.Dialog("ProFak", new UI.EkranSQL() { Kontekst = kontekst }, kontekst) { CzyPrzyciskiWidoczne = false };
dialog.ShowDialog();
}
if (args[0] == "db")
{
using var kontekst = new UI.Kontekst();
using var dialog = new UI.Dialog("ProFak", new UI.BazyDanych() { Kontekst = kontekst }, kontekst) { CzyPrzyciskiWidoczne = false };
dialog.ShowDialog();
}
return;
}
using (var kontekst = new UI.Kontekst())
{
var podmiot = kontekst.Baza.Kontrahenci.FirstOrDefault(kontrahent => kontrahent.CzyPodmiot);
if (podmiot == null)
{
MessageBox.Show("Przed rozpoczêciem korzystania z programu nale¿y uzupe³niæ dane firmy.", "ProFak", MessageBoxButtons.OK, MessageBoxIcon.Information);
var _ = Enumerable.Empty<DB.Kontrahent>();
new UI.MojaFirmaAkcja().Uruchom(kontekst, ref _);
}
}
Application.Run(new UI.GlowneOkno());
}
catch (Exception exc)
{
OknoBledu.Pokaz(exc);
}
}
}
}