123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Windows.Forms;
- using DevExpress.XtraEditors;
- using DevExpress.XtraGrid.Views.Grid;
- using UAS_PLCDataReader.Entity;
- using System.Collections.Generic;
- namespace UAS_PLCDataReader.CustomerControl.Button
- {
- public partial class ButtonDeleteRow : SimpleButton
- {
- private AutoDataGridControl.AutoDataGridControl grid;
- public AutoDataGridControl.AutoDataGridControl Grid
- {
- get
- {
- return grid;
- }
- set
- {
- grid = value;
- }
- }
- public ButtonDeleteRow()
- {
- InitializeComponent();
- }
- private void ButtonDeleteRow_Click(object sender, EventArgs e)
- {
- if (grid != null)
- {
- GridView view = grid.MainView as GridView;
- List<int> DeleteID = new List<int>();
- for (int i = 0; i < view.RowCount; i++)
- {
- if (view.GetRowCellValue(i, SystemInf.CheckedColumnName).ToString() != "0")
- DeleteID.Add(int.Parse(view.GetRowCellValue(i, grid.ID.ToUpper()).ToString()));
- }
- if (DeleteID.Count > 0)
- {
- DialogResult result = XtraMessageBox.Show("确认删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (result.ToString() == "Yes")
- {
- SystemInf.dh.DeleteDataByID(grid.TableName, grid.ID, DeleteID.ToArray());
- grid.RefreshData();
- }
- }
- else XtraMessageBox.Show("请选择要删除的数据", "提示");
- }
- }
- }
- }
|