-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrmEditVendor.cs
223 lines (187 loc) · 7.37 KB
/
FrmEditVendor.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LLGL2012
{
public partial class FrmEditVendor : Form
{
private static FrmEditVendor pUniqueForm = null;//窗体唯一打开代码
public static string falg = "Edit";
public static Boolean ifSave = false;
public static string pHzkhdm = "";
public static string pUnid = "";
public static string pCk = "";
public static string pHz = "";
public static string pTh = "";
public static string pFwdj = "";
public static string ResultHzkhdm = "'";
/// <summary>
/// 窗体唯一打开代码
/// </summary>
/// <param name="Path">是否作为模式窗体打开</param>
public static void ShowUniqueForm(bool AIfShowModal)
{
if (pUniqueForm == null)
{
new FrmEditVendor();
if (AIfShowModal) pUniqueForm.ShowDialog(); else pUniqueForm.Show();
}
}
public FrmEditVendor()
{
pUniqueForm = this;//窗体唯一打开代码
InitializeComponent();
}
private void FrmEditVendor_FormClosed(object sender, FormClosedEventArgs e)
{
pUniqueForm = null;//窗体唯一打开代码
}
private void FrmEditVendor_Load(object sender, EventArgs e)
{
ifSave = false;
string strCk = "select WHSE from V_WHSE ";
string strHz = "select COMPANY from v_company ";
string strTh = "select distinct t.ysfs therm_type from ysfs t where t.type='温度计字典'";
OleDbDataAdapter sda = new OleDbDataAdapter(strCk, CommFunction.ConnectString);
DataTable CKTable = new DataTable();
sda.Fill(CKTable);
for (int i = 0; i < CKTable.Rows.Count; i++)
{
lvCk.Items.Add(CKTable.Rows[i][0].ToString());
}
OleDbDataAdapter sda2 = new OleDbDataAdapter(strHz, CommFunction.ConnectString);
DataTable HzTable = new DataTable();
sda2.Fill(HzTable);
for (int i = 0; i < HzTable.Rows.Count; i++)
{
lvHz.Items.Add(HzTable.Rows[i][0].ToString());
}
OleDbDataAdapter sda3 = new OleDbDataAdapter(strTh, CommFunction.ConnectString);
DataTable ThTable = new DataTable();
sda3.Fill(ThTable);
for (int i = 0; i < ThTable.Rows.Count; i++)
{
therm_combo.Items.Add(ThTable.Rows[i][0].ToString());
}
Clean_Frm();
Load_Frm();
}
private void Clean_Frm()
{
tbHzKhdm.Text = "";
therm_combo.Text = "";
chbCk.Checked = false;
chbHz.Checked = false;
chbFwdj.Checked = false;
}
private void Load_Frm()
{
tbHzKhdm.Text = pHzkhdm;
if (falg == "Edit")
{
therm_combo.Text = pTh;
if (pFwdj == "附温度计") { chbFwdj.Checked = true; therm_combo.Enabled = true; } else { chbFwdj.Checked = false; therm_combo.Enabled = false; }
string[] sArray = pCk.Split(',');
if (sArray.Length > 0)
{
for (int i = 0; i < sArray.Length; i++)
{
for (int j = 0; j < lvCk.Items.Count; j++)
{
if (sArray[i].ToString() == lvCk.Items[j].Text.ToString()) { lvCk.Items[j].Checked = true; }
}
}
}
string[] sArray1 = pHz.Split(',');
if (sArray1.Length > 0)
{
for (int i = 0; i < sArray1.Length; i++)
{
for (int j = 0; j < lvHz.Items.Count; j++)
{
if (sArray1[i].ToString() == lvHz.Items[j].Text.ToString()) { lvHz.Items[j].Checked = true; }
}
}
}
}
}
private void chbCk_CheckedChanged(object sender, EventArgs e)
{
Boolean ch = chbCk.Checked;
for (int i = 0; i < lvCk.Items.Count; i++)
{
lvCk.Items[i].Checked = ch;
}
}
private void chbHz_CheckedChanged(object sender, EventArgs e)
{
Boolean ch = chbHz.Checked;
for (int i = 0; i < lvHz.Items.Count; i++)
{
lvHz.Items[i].Checked = ch;
}
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (tbHzKhdm.Text.Trim() == "") { MessageBox.Show("货主客户代码 不允许为空!"); return; }
string strCk = "";
string strHz = "";
string strFwdj = "";
string strTh = "";
for (int i = 0; i < lvCk.Items.Count; i++)
{
if (lvCk.Items[i].Checked) strCk = strCk + lvCk.Items[i].Text + ",";
}
for (int i = 0; i < lvHz.Items.Count; i++)
{
if (lvHz.Items[i].Checked) strHz = strHz + lvHz.Items[i].Text + ",";
}
if (chbFwdj.Checked)
{
strFwdj = "附温度计";
if (therm_combo.Text==""){ MessageBox.Show("选择附温度计后必须选择温度计类型!"); return; }
strTh = therm_combo.Text;
}
else
{
strFwdj = ""; strTh = "";
}
if (falg == "Add")
{
string SqlIns = "insert into cc_vendor_track(misc_instr_code_2,whse,season,ifthermometer,create_date_time,user_name,therm_type)"
+ "values('" + tbHzKhdm.Text.Trim() + "','" + strCk.Trim() + "','"
+ strHz.Trim() + "','" + strFwdj.Trim() + "',sysdate,'"
+ LoginCs.LoginClass.LogName +"','"+strTh.Trim()+ "')";
LYFunctionCs.LYFunctionCsClass.cmd(SqlIns, CommFunction.ConnectString);
}
else
{
string SqlUpdate = "update cc_vendor_track set whse='" + strCk.Trim() + "'," + "season='" + strHz.Trim() +
"',ifthermometer='" + strFwdj.Trim() + "',user_name='" + LoginCs.LoginClass.LogName +"',therm_type='"+strTh.Trim()+ "' " +
"where unid='" + pUnid + "'";
LYFunctionCs.LYFunctionCsClass.cmd(SqlUpdate, CommFunction.ConnectString);
}
ResultHzkhdm = ResultHzkhdm + "','" + tbHzKhdm.Text.Trim();
ifSave = true;
MessageBox.Show("完成。");
if (falg == "Add") { Clean_Frm(); } else { Close(); }
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
Close();
}
private void chbFwdj_CheckedChanged(object sender, EventArgs e)
{
if (chbFwdj.Checked)
therm_combo.Enabled = true;
else
therm_combo.Enabled = false;
}
}
}