using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using Gs.DevApp.Entity; using Gs.DevApp.ToolBox; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; namespace Gs.DevApp.DevFrm { public partial class Frm_Customer : DevExpress.XtraEditors.XtraForm { string _webServiceName = "MesCustomerManager/"; List _filterList = new List(); public Frm_Customer() { InitializeComponent(); this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick; gcMain.MouseDoubleClick += GcMain_MouseDoubleClick; gridView1.CustomDrawRowIndicator += GridView1_CustomDrawRowIndicator; pageBar1.PagerEvent += PageBar1_PagerEvent; getPageList(1, UtilityHelper.GetPageSize()); } private void GridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e) { if (e.Info.IsRowIndicator && e.RowHandle >= 0) { e.Info.DisplayText = (e.RowHandle + 1).ToString(); } } /// /// 双击事件 /// /// /// private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e) { string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid"); if (!string.IsNullOrEmpty(rowGuid)) getModel(rowGuid, false, 999); } /// /// 分页事件 /// /// /// private void PageBar1_PagerEvent(int curPage, int pageSize) { getPageList(curPage, pageSize); } /// /// 查询事件 /// /// /// private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e) { Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns, _filterList); frm.UpdateParent += Frm_UpdateParent; frm.ShowDialog(); } /// /// 查询回调 /// /// /// private void Frm_UpdateParent(object sender, UpdateParentEventArgs e) { _filterList = e.FilterList; getPageList(1, pageBar1.RowsCount); } /// /// 刷新事件 /// /// /// private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) { UtilityHelper.JumpToTab(xtraTabControl1, 0); getPageList(1, UtilityHelper.GetPageSize()); } /// /// /// /// 第几页 /// 每页几条 private void getPageList(int curPage, int pageSize) { System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder(); foreach (FilterEntity itm in _filterList) { _sbSqlWhere.Append(" and " + itm.fileId + itm.fileOper + "'" + itm.fileValue + "'"); } PageQueryModel pgq = new PageQueryModel(curPage, pageSize, "create_date", "asc", "", _sbSqlWhere.ToString()); string json = JsonConvert.SerializeObject(pgq); try { string strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json); ReturnModel dd = UtilityHelper.ReturnToTablePage(strReturn); if (dd.rtnCode > 0) { DataTable dt = dd.rtnData.list; gcMain.BindingContext = new BindingContext(); gcMain.DataSource = dt; gcMain.ForceInitialize(); int dddd = dd.rtnData.pages;//总页 pageBar1.TotalPages = dddd; pageBar1.RecordCount = dd.rtnData.total;//记录总数 pageBar1.CurrentPage = curPage;//当前页 pageBar1.RowsCount = pageSize;//每页显示 pageBar1.setTxt(); } else { ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg); } } catch (Exception ex) { ToolBox.MsgHelper.ShowError("提示:" + ex.Message); } } private void getModel(string strGuid, bool isEdit, int tabIdx) { if (string.IsNullOrEmpty(strGuid)) { ToolBox.MsgHelper.Warning("请先选择你要操作的行!"); return; } UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); var _obj = new { guid = strGuid,//主建 }; try { string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); ReturnModel _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { dynamic dy = _rtn.rtnData; lbGuid.Text = strGuid; UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit); } else ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); } catch (Exception ex) { ToolBox.MsgHelper.Warning("提示:" + ex.Message); } } } }