-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSUV.cs
712 lines (670 loc) · 26.8 KB
/
SUV.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Sunny.UI;
using i_car1;
namespace i_car3
{
public partial class Form3 : Form
{
public static Form3 SUV;
int c = 6;
int speed = 60; //全局变量
SqlConnection conn;
string constr = @"server=.\sqlexpress;database=2021040614;Integrated Security=true;";
public Form3()
{
InitializeComponent();
conn = new SqlConnection(constr);
SUV = this;
}
private void uiImageButton1_Click(object sender, EventArgs e)
{
Form6 f6 = new Form6();
f6.ShowDialog();
SqlConnection conn = new SqlConnection(constr);
}
private void uiImageButton2_Click(object sender, EventArgs e)
{
Form9 f9 = new Form9();
f9.ShowDialog();
}
private void uiImageButton3_MouseDown(object sender, MouseEventArgs e)
{
speed = 60; //左转
timer1.Enabled = true;
}
private void uiImageButton3_MouseUp(object sender, MouseEventArgs e)
{
timer1.Enabled = false;
}
private void uiImageButton4_MouseDown(object sender, MouseEventArgs e)
{
speed = -60; //左转
timer1.Enabled = true;
}
private void uiImageButton4_MouseUp(object sender, MouseEventArgs e)
{
timer1.Enabled = false;
}
private void uiRadioButton1_ValueChanged(object sender, bool value)
{
c = 1;
timer1.Enabled = true;
changecolor();
}
private void uiRadioButton3_ValueChanged(object sender, bool value)
{
c = 2;
timer1.Enabled = true;
changecolor();
}
private void uiRadioButton5_ValueChanged(object sender, bool value)
{
c = 3;
timer1.Enabled = true;
changecolor();
}
private void uiRadioButton2_ValueChanged(object sender, bool value)
{
c = 4;
timer1.Enabled = true;
changecolor();
}
private void uiRadioButton4_ValueChanged(object sender, bool value)
{
c = 5;
timer1.Enabled = true;
changecolor();
}
private void uiRadioButton6_ValueChanged(object sender, bool value)
{
c = 6;
timer1.Enabled = true;
changecolor();
}
private void changecolor()
{
axUnityWebPlayer1.SendMessage("carpaint_antena", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_body_l", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_body_r", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_bumper_f", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_bumper_grill", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_bumper_top", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_doors_f", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_doors_r", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_fenders_f", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_hood", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_mirrors", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_roof", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_tailgate", "colorchangeC", c);
axUnityWebPlayer1.SendMessage("carpaint_tailgate_top", "colorchangeC", c);
}
private void timer1_Tick(object sender, EventArgs e)
{
axUnityWebPlayer1.SendMessage("AudiQ8_2019_hi", "rotateX", speed);
}
int index = 0;
ImageList il = new ImageList();
private void Form3_Load(object sender, EventArgs e)
{
il = imageList1;
pictureBox24.Image = il.Images[0];
//默认选项
uiRadioButton19.Checked = true;//发动机
uiRadioButton1.Checked = true;// 车的颜色
uiRadioButton13.Checked = true;//轮毂颜色
uiRadioButton7.Checked = true;//天窗
uiRadioButton9.Checked = true;//车的颜色
uiRadioButton22.Checked = true;//风格颜色
//默认座位颜色预览
il = imageList1;
pictureBox24.Image = il.Images[index];
uiRadioButton26.Checked = true;//真皮装备包
uiRadioButton28.Checked = true;//真皮装备包
uiRadioButton10.Checked = true;//后视镜
uiCheckBox30.Checked = true;//照明
uiCheckBox43.Checked = true;//照明
uiCheckBox45.Checked = true;//照明
uiCheckBox30.Enabled = false;
uiCheckBox43.Enabled = false;
uiCheckBox45.Enabled = false;
uiCheckBox11.Checked = true;//娱乐
uiCheckBox9.Checked = true;//娱乐
uiCheckBox14.Checked = true;//娱乐
uiCheckBox11.Enabled = false;//娱乐
uiCheckBox9.Enabled = false;//娱乐
uiCheckBox14.Enabled = false;//娱乐
uiCheckBox19.Checked = true;//娱乐
//生产订单号
Class1.订单号 = Class1.姓名 + DateTime.Now.ToFileTimeUtc().ToString();
uiLabel14.Text = Class1.订单号;
}
private void pictureBox25_Click(object sender, EventArgs e)
{
il = imageList1;
pictureBox24.Image = il.Images[index];
}
private void pictureBox26_Click(object sender, EventArgs e)
{
il = imageList2;
pictureBox24.Image = il.Images[index];
}
private void pictureBox27_Click(object sender, EventArgs e)
{
il = imageList3;
pictureBox24.Image = il.Images[index];
}
private void pictureBox28_Click(object sender, EventArgs e)
{
il = imageList4;
pictureBox24.Image = il.Images[index];
}
private void uiImageButton7_Click(object sender, EventArgs e)
{
index--;
if (index < 0)
{
index = il.Images.Count - 1;//如果下标正好等于数组大小,说明超了,就赋个0,从头开始 if(index == imageList1.Images.Count)
}
pictureBox24.Image = il.Images[index];
}
private void uiImageButton5_Click(object sender, EventArgs e)
{
index++;
if (index == il.Images.Count)
{
index = 0;//如果下标正好等于数组大小,说明超了,就赋个0,从头开始 if(index == imageList1.Images.Count)
}
pictureBox24.Image = il.Images[index];
}
private void pictureBox24_Click(object sender, EventArgs e)
{
index++;
if (index == il.Images.Count)
{
index = 0;//如果下标正好等于数组大小,说明超了,就赋个0,从头开始 if(index == imageList1.Images.Count)
}
pictureBox24.Image = il.Images[index];
}
private void uiContextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
string sql删除 = @"delete from orderparts where 订单编号=@订单编号";
SqlCommand cmd删除 = new SqlCommand(sql删除, conn);
cmd删除.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
try
{
conn.Open();
cmd删除.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
string sql删除2 = @"delete from order1 where 订单编号=@订单编号";
SqlCommand cmd删除2 = new SqlCommand(sql删除2, conn);
cmd删除2.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
try
{
conn.Open();
cmd删除2.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
}
//自定义参数输入函数(radiobutton6:)
private void setpara(UIRadioButton uIRadioButton)
{
if (uIRadioButton.Checked)
{
string sql1 = @"select 零件编号 from components where 零件名称=@零件名称";
SqlCommand cmd = new SqlCommand(sql1, conn);
cmd.Parameters.Add("@零件名称", SqlDbType.NVarChar, 100).Value = uIRadioButton.Text;
try
{
conn.Open();
Class1.零件编号 = cmd.ExecuteScalar().ToString();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
string sql2 = @"insert into orderparts
values(@订单编号,@零件编号)";
SqlCommand cmd2 = new SqlCommand(sql2, conn);
cmd2.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
cmd2.Parameters.Add("@零件编号", SqlDbType.NVarChar, 5).Value = Class1.零件编号;
try
{
conn.Open();
cmd2.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
}
}
//自定义参数输入函数(checkbox)
private void setpara1(UICheckBox uICheckBox)
{
if (uICheckBox.Checked)
{
string sql1 = @"select 零件编号 from components where 零件名称=@零件名称";
SqlCommand cmd = new SqlCommand(sql1, conn);
cmd.Parameters.Add("@零件名称", SqlDbType.NVarChar, 100).Value = uICheckBox.Text;
try
{
conn.Open();
Class1.零件编号 = cmd.ExecuteScalar().ToString();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
string sql2 = @"insert into orderparts
values(@订单编号,@零件编号)";
SqlCommand cmd2 = new SqlCommand(sql2, conn);
cmd2.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
cmd2.Parameters.Add("@零件编号", SqlDbType.NVarChar, 5).Value = Class1.零件编号;
try
{
conn.Open();
cmd2.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
}
}
private void uiImageButton11_Click(object sender, EventArgs e)
{
//先删除旧表orderparts
string sql删除 = @"delete from orderparts where 订单编号=@订单编号";
SqlCommand cmd删除 = new SqlCommand(sql删除, conn);
cmd删除.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
try
{
conn.Open();
cmd删除.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
//再删除旧表order1
string sql删除2 = @"delete from order1 where 订单编号=@订单编号";
SqlCommand cmd删除2 = new SqlCommand(sql删除2, conn);
cmd删除2.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
try
{
conn.Open();
cmd删除2.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
//插入order1
string sql0 = @"insert into order1(订单编号,用户名,汽车名称,颜色,下单时间)
values(@订单编号,@用户名,@汽车名称,@颜色,@下单时间)";
SqlCommand cmd0 = new SqlCommand(sql0, conn);
cmd0.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
cmd0.Parameters.Add("@用户名", SqlDbType.NVarChar, 50).Value = Class1.用户名;
cmd0.Parameters.Add("@汽车名称", SqlDbType.NVarChar, 50).Value = "奥迪Q8";
if (uiRadioButton1.Checked)
Class1.颜色 = uiRadioButton1.Text;
else if (uiRadioButton2.Checked)
Class1.颜色 = uiRadioButton2.Text;
else if (uiRadioButton3.Checked)
Class1.颜色 = uiRadioButton3.Text;
else if (uiRadioButton4.Checked)
Class1.颜色 = uiRadioButton4.Text;
else if (uiRadioButton5.Checked)
Class1.颜色 = uiRadioButton5.Text;
else if (uiRadioButton6.Checked)
Class1.颜色 = uiRadioButton6.Text;
cmd0.Parameters.Add("@颜色", SqlDbType.NVarChar, 50).Value = Class1.颜色;
cmd0.Parameters.Add("@下单时间", SqlDbType.NVarChar, 50).Value = DateTime.Now.ToString();
try
{
conn.Open();
cmd0.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
//参数输入
foreach (Control control in this.Controls)
{
if (control is UIRadioButton)
{
UIRadioButton ur = (UIRadioButton)control;
setpara(ur);
}
}
setpara(uiRadioButton7);
setpara(uiRadioButton8);
setpara(uiRadioButton9);
setpara(uiRadioButton10);
setpara(uiRadioButton11);
setpara(uiRadioButton12);
setpara(uiRadioButton13);
setpara(uiRadioButton14);
setpara(uiRadioButton15);
setpara(uiRadioButton16);
setpara(uiRadioButton17);
setpara(uiRadioButton18);
setpara(uiRadioButton19);
setpara(uiRadioButton20);
setpara(uiRadioButton21);
setpara(uiRadioButton22);
setpara(uiRadioButton23);
setpara(uiRadioButton24);
setpara(uiRadioButton25);
setpara(uiRadioButton26);
setpara(uiRadioButton27);
setpara(uiRadioButton28);
setpara(uiRadioButton29);
setpara1(uiCheckBox10);
setpara1(uiCheckBox11);
setpara1(uiCheckBox12);
setpara1(uiCheckBox13);
setpara1(uiCheckBox14);
setpara1(uiCheckBox15);
setpara1(uiCheckBox16);
setpara1(uiCheckBox17);
setpara1(uiCheckBox18);
setpara1(uiCheckBox19);
setpara1(uiCheckBox20);
setpara1(uiCheckBox21);
setpara1(uiCheckBox22);
setpara1(uiCheckBox23);
setpara1(uiCheckBox24);
setpara1(uiCheckBox25);
setpara1(uiCheckBox26);
setpara1(uiCheckBox27);
setpara1(uiCheckBox28);
setpara1(uiCheckBox29);
setpara1(uiCheckBox30);
setpara1(uiCheckBox31);
setpara1(uiCheckBox32);
setpara1(uiCheckBox33);
setpara1(uiCheckBox34);
setpara1(uiCheckBox35);
setpara1(uiCheckBox36);
setpara1(uiCheckBox37);
setpara1(uiCheckBox38);
setpara1(uiCheckBox39);
setpara1(uiCheckBox40);
setpara1(uiCheckBox41);
setpara1(uiCheckBox42);
setpara1(uiCheckBox43);
setpara1(uiCheckBox44);
setpara1(uiCheckBox45);
setpara1(uiCheckBox46);
setpara1(uiCheckBox47);
setpara1(uiCheckBox48);
setpara1(uiCheckBox49);
setpara1(uiCheckBox50);
setpara1(uiCheckBox51);
setpara1(uiCheckBox52);
string sqlm = @"select 零件种类,零件名称,价格 from components,orderparts
where components.零件编号=orderparts.零件编号
and 订单编号=@订单编号 order by 价格";
SqlCommand cmdm = new SqlCommand(sqlm, conn);
cmdm.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
SqlDataAdapter ad = new SqlDataAdapter(cmdm);
DataTable dt = new DataTable();
ad.Fill(dt);
uiDataGridView1.DataSource = dt;
//总价计算
string sqlprice = @"select 基础价格 from cars where 汽车名称='奥迪Q8'";
SqlCommand cmdprice = new SqlCommand(sqlprice, conn);
try
{
conn.Open();
Class1.基础价格 = int.Parse(cmdprice.ExecuteScalar().ToString());
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
int c = dt.Rows.Count;
int price2 = 0;
for (int i = 0; i < c; i++)
{
price2 += int.Parse(dt.Rows[i][2].ToString());
}
price2 = price2 + Class1.基础价格;
Class1.总价 = price2;
uiLabel17.Text = price2.ToString() + "元";
string sql总价 = @"update order1 set 总价 =@总价 where 订单编号=@订单编号";
SqlCommand cmd总价 = new SqlCommand(sql总价, conn);
cmd总价.Parameters.Add("@总价", SqlDbType.Int).Value = Class1.总价;
cmd总价.Parameters.Add("@订单编号", SqlDbType.NVarChar, 255).Value = Class1.订单号;
try
{
conn.Open();
cmd总价.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
}//选配过程
private void uiImageButton15_Click(object sender, EventArgs e)
{
string sql1 = @"select 零件编号 from components where 零件名称=@零件名称";
SqlCommand cmd = new SqlCommand(sql1, conn);
cmd.Parameters.Add("@零件名称", SqlDbType.NVarChar, 100).Value = uiDataGridView1.CurrentRow.Cells[1].Value.ToString();
try
{
conn.Open();
Class1.零件编号 = cmd.ExecuteScalar().ToString();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
string sql2 = @"delete from orderparts where 订单编号=@订单编号 and 零件编号=@零件编号";
SqlCommand cmd2 = new SqlCommand(sql2, conn);
cmd2.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
cmd2.Parameters.Add("@零件编号", SqlDbType.NVarChar, 5).Value = Class1.零件编号;
try
{
conn.Open();
cmd2.ExecuteNonQuery();
MessageBox.Show("删除成功");
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
string sqlm = @"select 零件种类,零件名称,价格 from components,orderparts
where components.零件编号=orderparts.零件编号
and 订单编号=@订单编号 order by 价格" ;
SqlCommand cmdm = new SqlCommand(sqlm, conn);
cmdm.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
SqlDataAdapter ad = new SqlDataAdapter(cmdm);
DataTable dt = new DataTable();
ad.Fill(dt);
uiDataGridView1.DataSource = dt;
int c = dt.Rows.Count;
int price2 = 0;
for (int i = 0; i < c; i++)
{
price2 += int.Parse(dt.Rows[i][2].ToString());
}
price2 = price2 + Class1.基础价格;
Class1.总价 = price2;
uiLabel17.Text = price2.ToString() + "元";
string sql总价 = @"update order1 set 总价 =@总价 where 订单编号=@订单编号";
SqlCommand cmd总价 = new SqlCommand(sql总价, conn);
cmd总价.Parameters.Add("@总价", SqlDbType.Int).Value = Class1.总价;
cmd总价.Parameters.Add("@订单编号", SqlDbType.VarChar, 20).Value = Class1.订单号;
try
{
conn.Open();
cmd总价.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
}//删除已选零件并更新
private void uiImageButton13_Click(object sender, EventArgs e)
{
new 说明().Show();
Form f6 = new 说明();
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
string sql1 = @"select 零件编号 from components where 零件名称=@零件名称";
SqlCommand cmd = new SqlCommand(sql1, conn);
cmd.Parameters.Add("@零件名称", SqlDbType.NVarChar, 100).Value = uiDataGridView1.CurrentRow.Cells[1].Value.ToString();
try
{
conn.Open();
Class1.零件编号 = cmd.ExecuteScalar().ToString();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
string sql2 = @"delete from orderparts where 订单编号=@订单编号 and 零件编号=@零件编号";
SqlCommand cmd2 = new SqlCommand(sql2, conn);
cmd2.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
cmd2.Parameters.Add("@零件编号", SqlDbType.NVarChar, 5).Value = Class1.零件编号;
try
{
conn.Open();
cmd2.ExecuteNonQuery();
MessageBox.Show("删除成功");
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}
string sqlm = @"select 零件种类,零件名称,价格 from components,orderparts
where components.零件编号=orderparts.零件编号
and 订单编号=@订单编号 order by 价格";
SqlCommand cmdm = new SqlCommand(sqlm, conn);
cmdm.Parameters.Add("@订单编号", SqlDbType.NVarChar, 50).Value = Class1.订单号;
SqlDataAdapter ad = new SqlDataAdapter(cmdm);
DataTable dt = new DataTable();
ad.Fill(dt);
uiDataGridView1.DataSource = dt;
int c = dt.Rows.Count;
int price2 = 0;
for (int i = 0; i < c; i++)
{
price2 += int.Parse(dt.Rows[i][2].ToString());
}
price2 = price2 + Class1.基础价格;
Class1.总价 = price2;
uiLabel17.Text = price2.ToString() + "元";
string sql总价 = @"update order1 set 总价 =@总价 where 订单编号=@订单编号";
SqlCommand cmd总价 = new SqlCommand(sql总价, conn);
cmd总价.Parameters.Add("@总价", SqlDbType.Int).Value = Class1.总价;
cmd总价.Parameters.Add("@订单编号", SqlDbType.VarChar, 20).Value = Class1.订单号;
try
{
conn.Open();
cmd总价.ExecuteNonQuery();
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString(), "失败");
}
finally
{
conn.Close();
}//删除订单
}
private void axUnityWebPlayer1_OnExternalCall(object sender, AxUnityWebPlayerAXLib._DUnityWebPlayerAXEvents_OnExternalCallEvent e)
{
}
private void uiRadioButton14_ValueChanged(object sender, bool value)
{
}
private void pictureBox36_Click(object sender, EventArgs e)
{
}
}
}