-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form8.txt
94 lines (84 loc) · 3.14 KB
/
Form8.txt
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AnalizHelperSystem
{
public partial class Form8 : Form
{
DBwork dbw1 = new DBwork(SqlConnectionParametrs.DataBaseName, SqlConnectionParametrs.DataBaseServiceName);
private string c_factor_name = "";
private string c_factor_def = "";
delegate void Delegate();
Delegate del1;
Delegate del2;
Delegate del3;
public Form8()
{
InitializeComponent();
del1 = comboBox1_readFactors;
del2 = comboBox1_SelectChanged;
comboBox1.DisplayMember = "Name_fact";
comboBox1.ValueMember = "Name_fact";
groupBox1.Enabled = false;
pictureBox1.Visible = true;
backgroundWorker1.RunWorkerAsync(del1);
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
groupBox1.Enabled = false;
pictureBox1.Visible = true;
backgroundWorker1.RunWorkerAsync(del2);
}
private void button1_Click(object sender, EventArgs e)
{
dbw1.ChangeDataInDataBase("QUIM", "update Factor set name_fact = '" + textBox1.Text + "', def_fact = '" + richTextBox1.Text + "' where name_fact like '" + comboBox1.GetItemText(comboBox1.Items[comboBox1.SelectedIndex]) + "'");
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form8_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
button1.PerformClick();
}
if (e.KeyChar == (char)Keys.Escape)
{
button2.PerformClick();
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
Delegate delTemp = e.Argument as Delegate;
delTemp();
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
pictureBox1.Visible = false;
groupBox1.Enabled = true;
if (e.Error != null)
{
MessageBox.Show(this, e.Error.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void comboBox1_readFactors()
{
DataSet dataSet1 = dbw1.ReadFactors();
comboBox1.DataSource = dataSet1.Tables[0];
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
}
private void comboBox1_SelectChanged()
{
DataSet dataSet1 = dbw1.ReadDataBaseToDataSet("QUIM", "select name_fact, def_fact from Factor where name_fact like '" + comboBox1.Text + "'");
textBox1.Text = dataSet1.Tables[0].Rows[0].ItemArray[0].ToString();
richTextBox1.Text = dataSet1.Tables[0].Rows[0].ItemArray[1].ToString();
}
}
}