using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraEditors; using Uninpho.DBOperation.Model; using Uninpho.DBOperation.Operation; namespace Uninpho.Tools.components.TZFunc { public partial class GJInform : DevExpress.XtraEditors.XtraUserControl { public GJInform() { InitializeComponent(); //data_binding(); } /// /// 显示序号。 /// /// /// private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) { if (e.Info.Kind == DevExpress.Utils.Drawing.IndicatorKind.Header) { e.Appearance.DrawBackground(e.Cache, e.Bounds); e.Appearance.DrawString(e.Cache, " 序号", e.Bounds); e.Handled = true; } if (e.Info.IsRowIndicator && e.RowHandle >= 0) { e.Info.DisplayText = (e.RowHandle + 1).ToString(); } } public void data_binding() { List guanjieList = SqlQueryable_QX.Search_GJ(); this.gridControl_GJ.DataSource = guanjieList; } private void deletebtngj_Click(object sender, EventArgs e) { if (UserInform.userinf.Pow == 0) { XtraMessageBox.Show("您无权删除数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var selectRowId = this.gridView1.GetSelectedRows(); if (selectRowId.Length == 0) { XtraMessageBox.Show("请选中删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (this.Confirm("是否删除") == DialogResult.OK) { List deletelist = new List(); foreach (var item in selectRowId) { deletelist.Add(new T_guanjie_account() { Id = this.gridView1.GetRowCellValue(item, "Id").ToString() }); } SqlQueryable_QX.GJDeleteRows(deletelist); XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.data_binding(); } else { return; } } } } //弹出提示况 public DialogResult Confirm(string strString) { return DevExpress.XtraEditors.XtraMessageBox.Show(strString, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); } private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Value == null || e.Value == "") { XtraMessageBox.Show("请勿填写空值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } T_guanjie_account rowdata = this.gridView1.GetRow(e.RowHandle) as T_guanjie_account; SqlQueryable_QX.GJUpdataRowData(rowdata); } } }