-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddUserForm.cs
More file actions
68 lines (56 loc) · 2.05 KB
/
AddUserForm.cs
File metadata and controls
68 lines (56 loc) · 2.05 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.IO;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using MySQLData;
namespace jsu1xd
{
public partial class AddUserForm : Form
{
string strPath = System.Environment.GetEnvironmentVariable("TEMP");
public AddUserForm()
{
InitializeComponent();
}
private void guna2Button1_Click(object sender, EventArgs e)
{
if (guna2TextBox1.Text == "")
{
MessageBox.Show("Введите известуню вам информацию");
return;
}
guna2Button1.Enabled = false;
var dbCon = DBConnection.Instance();
if (dbCon.IsConnect())
{
string info = guna2TextBox1.Text;
string comment;
if (guna2TextBox2.Text == "")
{
comment = "Не указан";
} else
{
comment = guna2TextBox2.Text;
}
string query;
string path = Path.Combine(strPath, "jsu1xd.tmp");
using (var sr = new StreamReader(path))
{
int user_id = Convert.ToInt32(sr.ReadToEnd());
query = "INSERT INTO `requests` (`user`, `info`, `comment`, `status`)" +
$"VALUES ({user_id}, '{info}', '{comment}', 'WAIT')";
}
var cmd = new MySqlCommand(query, dbCon.Connection);
cmd.ExecuteNonQuery();
MessageBox.Show("Заявка оставлена успешно, ожидайте ее расмотрения!");
dbCon.Close();
this.Close();
}
else
{
MessageBox.Show("Ошибка подключения. Проверьте свое соединение с интернетом и попробуйте позднее");
guna2Button1.Enabled = true;
}
}
}
}