DCInform.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.Operation;
  12. using Uninpho.DBOperation.Model;
  13. namespace Uninpho.Tools.components.TZFunc
  14. {
  15. public partial class DCInform : DevExpress.XtraEditors.XtraUserControl
  16. {
  17. public DCInform()
  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. e.Appearance.DrawString(e.Cache, " 序号", e.Bounds);
  39. }
  40. }
  41. public void data_binding()
  42. {
  43. //Console.WriteLine("lll");
  44. List<T_daocha_account> daochaList = SqlQueryable_QX.Search_DC();
  45. this.gridControl_DC.DataSource = daochaList;
  46. }
  47. private void panelControl2_Paint(object sender, PaintEventArgs e)
  48. {
  49. }
  50. /// <summary>
  51. /// 删除数据
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. private void deletebtn_Click(object sender, EventArgs e)
  56. {
  57. if (UserInform.userinf.Pow == 0)
  58. {
  59. XtraMessageBox.Show("您无权删除数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  60. }
  61. else
  62. {
  63. var selectRowId = this.gridView1.GetSelectedRows();
  64. if (selectRowId.Length == 0)
  65. {
  66. XtraMessageBox.Show("请选中删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  67. return;
  68. }
  69. else
  70. {
  71. if (this.Confirm("是否删除") == DialogResult.OK)
  72. {
  73. List<T_daocha_account> deletelist = new List<T_daocha_account>();
  74. foreach (var item in selectRowId)
  75. {
  76. deletelist.Add(new T_daocha_account() { Id = this.gridView1.GetRowCellValue(item, "Id").ToString() });
  77. }
  78. SqlQueryable_QX.DCDeleteRows(deletelist);
  79. XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  80. this.data_binding();
  81. }
  82. else
  83. {
  84. return;
  85. }
  86. }
  87. }
  88. }
  89. //弹出提示况
  90. public DialogResult Confirm(string strString)
  91. {
  92. return DevExpress.XtraEditors.XtraMessageBox.Show(strString, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  93. }
  94. private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  95. {
  96. if (e.Value == null || e.Value == "")
  97. {
  98. XtraMessageBox.Show("请勿填写空值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  99. return;
  100. }
  101. T_daocha_account rowdata = this.gridView1.GetRow(e.RowHandle) as T_daocha_account;
  102. SqlQueryable_QX.DCUpdataRowData(rowdata);
  103. }
  104. }
  105. }