1 存储过程部分:
2
3 USE [JohnsonI]
4 GO
5 /****** Object: StoredProcedure [dbo].[sp_DELETE_PLAN_AUTO] Script Date: 03/15/2013 17:29:43 ******/
6 SET ANSI_NULLS ON
7 GO
8 SET QUOTED_IDENTIFIER ON
9 GO
10 -- =============================================
11 -- Author:
12 -- Create date:
13 -- Description:
14 -- =============================================
15 ALTER PROCEDURE [dbo].[sp_DELETE_PLAN_AUTO]
16 @ID int
17 AS
18 BEGIN
19 DELETE FROM T_PLAN_AUTO WHERE ID=@ID
20 END
21
22
23
24 DAL层:
25
26
27
28 public int DELETE_PLAN_AUTO(int[] id)
29 {
30 int result = 0;
31 for (int i = 0; i )
32 {
33 SqlParameter[] parameter = {
34 new SqlParameter ("@ID",id[i])
35 };
36 CsDbHelperSql.RunProcedureExecuteNonQuery("sp_DELETE_PLAN_AUTO", parameter, out result, connstr);
37
38 }
39 return result;
40
41
42
43
44 }
45
46 BLL层:
47
48 public bool DELETE_PLAN_AUTO(int[] id)
49 {
50 int i = _dal.DELETE_PLAN_AUTO(id);
51 return i > 0;
52 }
53
54 UI层:
55
56 private void btn_planCanncel_Click(object sender, EventArgs e)
57 {
58 if (MessageBox.Show("确定要删除吗", "警告", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK)
59 {
60 return;
61 }
62 else
63 {
64 List<int> list = new List<int>();
65 for (int i = this.dataGridView1.SelectedRows.Count; i > 0; i--)
66 {
67 int id = Convert.ToInt32(dataGridView1.SelectedRows[i - 1].Cells[0].Value);
68 dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[i - 1].Index);
69 list.Add(id);
70 }
71 if (list.Count > 0)
72 {
73 bool IsTrue = _bll_plan_auto.DELETE_PLAN_AUTO(list.ToArray());
74 if (IsTrue)
75 {
76 MessageBox.Show("删除成功!");
77 }
78 else
79 {
80 MessageBox.Show("删除失败");
81 }
82 }
83 else
84 {
85 MessageBox.Show("出现异常");
86 }
87 }
88
89
90
91 }
92
93
94
95
96
97