ButtonDeleteRow.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using DevExpress.XtraEditors;
  10. using DevExpress.XtraGrid.Views.Grid;
  11. using UAS_DeviceMonitor.Entity;
  12. namespace UAS_DeviceMonitor.CustomerControl.Button
  13. {
  14. public partial class ButtonDeleteRow : SimpleButton
  15. {
  16. private AutoDataGridControl.AutoDataGridControl grid;
  17. public AutoDataGridControl.AutoDataGridControl Grid
  18. {
  19. get
  20. {
  21. return grid;
  22. }
  23. set
  24. {
  25. grid = value;
  26. }
  27. }
  28. public ButtonDeleteRow()
  29. {
  30. InitializeComponent();
  31. }
  32. private void ButtonDeleteRow_Click(object sender, EventArgs e)
  33. {
  34. if (grid != null)
  35. {
  36. GridView view = grid.MainView as GridView;
  37. int[] DeleteID = view.GetSelectedRows();
  38. for (int i = 0; i < DeleteID.Length; i++)
  39. {
  40. DeleteID[i] = int.Parse(view.GetRowCellValue(i, grid.ID.ToUpper()).ToString());
  41. }
  42. if (DeleteID.Length > 0)
  43. {
  44. DialogResult result = XtraMessageBox.Show("确认删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  45. if (result.ToString() == "Yes")
  46. {
  47. SystemInf.dh.DeleteDataByID(grid.TableName, grid.ID, DeleteID);
  48. grid.RefreshData();
  49. }
  50. }
  51. else XtraMessageBox.Show("请选择要删除的数据", "提示");
  52. }
  53. }
  54. }
  55. }