-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
43 lines (38 loc) · 1.28 KB
/
Main.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
using SQLBakVersion.Class;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace SQLBakVersion
{
public partial class Main : Form
{
private readonly SQLVersion sqlVersion = new SQLVersion();
public Main()
{
InitializeComponent();
}
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "SQL Server backup files (*.bak)|*.bak";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
txtBakFilePath.Text = openFileDialog.FileName;
}
string filePath = txtBakFilePath.Text;
string output = string.Empty;
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
output = "Please select a valid .bak file.";
else
output = sqlVersion.GetVersion(filePath);
lblVersion.Text = output;
if (output.StartsWith("SQL"))
lblVersion.ForeColor = Color.LightGreen;
else
lblVersion.ForeColor = Color.Red;
if (!lblVersion.Visible)
lblVersion.Visible = true;
}
}
}