GJInform.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Text;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using Uninpho.DBOperation.Model;
  12. using Uninpho.DBOperation.Operation;
  13. namespace Uninpho.Tools.components.TZFunc
  14. {
  15. public partial class GJInform : DevExpress.XtraEditors.XtraUserControl
  16. {
  17. public GJInform()
  18. {
  19. InitializeComponent();
  20. //data_binding();
  21. }
  22. /// <summary>
  23. /// 显示序号。
  24. /// </summary>
  25. /// <param name="sender"></param>
  26. /// <param name="e"></param>
  27. private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  28. {
  29. if (e.Info.Kind == DevExpress.Utils.Drawing.IndicatorKind.Header)
  30. {
  31. e.Appearance.DrawBackground(e.Cache, e.Bounds);
  32. e.Appearance.DrawString(e.Cache, " 序号", e.Bounds);
  33. e.Handled = true;
  34. }
  35. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  36. {
  37. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  38. }
  39. }
  40. public void data_binding()
  41. {
  42. List<T_guanjie_account> guanjieList = SqlQueryable_QX.Search_GJ();
  43. this.gridControl_GJ.DataSource = guanjieList;
  44. }
  45. private void deletebtngj_Click(object sender, EventArgs e)
  46. {
  47. if (UserInform.userinf.Pow == 0)
  48. {
  49. XtraMessageBox.Show("您无权删除数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  50. }
  51. else
  52. {
  53. var selectRowId = this.gridView1.GetSelectedRows();
  54. if (selectRowId.Length == 0)
  55. {
  56. XtraMessageBox.Show("请选中删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  57. return;
  58. }
  59. else
  60. {
  61. if (this.Confirm("是否删除") == DialogResult.OK)
  62. {
  63. List<T_guanjie_account> deletelist = new List<T_guanjie_account>();
  64. foreach (var item in selectRowId)
  65. {
  66. deletelist.Add(new T_guanjie_account() { Id = this.gridView1.GetRowCellValue(item, "Id").ToString() });
  67. }
  68. SqlQueryable_QX.GJDeleteRows(deletelist);
  69. XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  70. this.data_binding();
  71. }
  72. else
  73. {
  74. return;
  75. }
  76. }
  77. }
  78. }
  79. //弹出提示况
  80. public DialogResult Confirm(string strString)
  81. {
  82. return DevExpress.XtraEditors.XtraMessageBox.Show(strString, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  83. }
  84. private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  85. {
  86. if (e.Value == null || e.Value == "")
  87. {
  88. XtraMessageBox.Show("请勿填写空值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  89. return;
  90. }
  91. T_guanjie_account rowdata = this.gridView1.GetRow(e.RowHandle) as T_guanjie_account;
  92. SqlQueryable_QX.GJUpdataRowData(rowdata);
  93. }
  94. }
  95. }