using DevExpress.XtraEditors; using HL_FristAidPlatform_Public; using System; using System.Data; namespace HL_FristAidPlatform_KnowledgeBase { public partial class Form_Knowledge_ConstructionMaterialsMain : XtraForm { #region 变量 /// /// 当前页 /// private int curPage = 1; /// /// 每页大小 /// private int pageSize = 100; /// /// 所有记录条数 /// private int totalNumber = 0; #endregion #region 分页实现 public void ExportEvents(bool singlePage)//单页,所有 { //导出GridControl代码写在这。 } public void RefreshGridList() { FillGridListCtrlQuery(curPage);//自己实现FillGridListCtrlQuery函数。 } /// /// 绑定数据源 /// /// private void FillGridListCtrlQuery(int curPage) { try { string strParameter = string.Empty; //认证中心 string SystemModuleID = PublicClass.ToString(radioGroup_SystemModuleID.EditValue, ""); if (!string.IsNullOrEmpty(SystemModuleID)) { strParameter += "&systemModuleID=" + SystemModuleID; } //认证版本 string VersionGUID = PublicClass.ToString(radioGroup_VersionGUID.EditValue, ""); if (!string.IsNullOrEmpty(VersionGUID)) { strParameter += "&versionGUID=" + VersionGUID; } //关键词 if (!string.IsNullOrEmpty(txt_Key.Text.ToString().Trim())) { strParameter += "&key=" + txt_Key.Text.ToString().Trim(); } string Url = string.Format("api/base/T_Base_ConstructionMaterials?pageIndex={0}&pageSize={1}{2}", curPage, pageSize, strParameter); ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); DataTable patientDT = client.Get(Url, Enumerate.Platform.首辰健康, out totalNumber); grid_List.DataSource = patientDT; grv_List.BestFitColumns();//列宽自适应 userControlForPage.RefreshPager(pageSize, totalNumber, curPage);//更新分页控件显示。 } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定数据源:\r\n" + ex); } } private void MyPagerEvents(int curPage, int pageSize) { this.curPage = curPage; this.pageSize = pageSize; FillGridListCtrlQuery(curPage); } private void userControlForPage_exportEvents(bool singlePage) { userControlForPage.exportEvents += ExportEvents; } private void userControlForPage_myPagerEvents(int curPage, int pageSize) { userControlForPage.myPagerEvents += MyPagerEvents; } #endregion public Form_Knowledge_ConstructionMaterialsMain() { InitializeComponent(); } /// /// 窗体加载 /// /// /// private void Form_Knowledge_ConstructionMaterialsMain_Load(object sender, EventArgs e) { BindData(); } #region BindData /// /// 查询绑定 /// private void BindData() { BindSystemModule(); } /// /// 绑定所属系统模块 /// private void BindSystemModule() { try { DataTable ResultDT = DBHelpClass.Get("/api/admin/T_SYS_SystemModule/GetIsHaveTimeAxisList?isHaveTimeAxis=0"); PublicClass.BindRadioGroupData(radioGroup_SystemModuleID, ResultDT, "ShortName", "ID"); } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定所属系统模块:\r\n" + ex); } } /// /// 认证中心选项更改 /// /// /// private void radioGroup_SystemModuleID_EditValueChanged(object sender, EventArgs e) { string EditValue = PublicClass.ToString(radioGroup_SystemModuleID.EditValue, ""); if (!string.IsNullOrEmpty(EditValue)) { BindVersion(EditValue); } } /// /// 绑定认证版本选项 /// /// 所选系统编号 private void BindVersion(string systemModuleID) { try { radioGroup_VersionGUID.Properties.Items.Clear(); DataTable ResultDT = DBHelpClass.Get(string.Format("api/base/T_Base_CertificationVersion?systemModuleID={0}", systemModuleID)); PublicClass.BindRadioGroupData(radioGroup_VersionGUID, ResultDT, "VersionName", "GUID"); } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定认证版本选项:\r\n" + ex); } } #endregion /// /// 查询列表 /// /// /// private void radioGroup_VersionGUID_SelectedIndexChanged(object sender, EventArgs e) { RefreshGridList(); } /// /// 查询按钮单击事件 /// /// /// private void btn_Search_Click(object sender, EventArgs e) { RefreshGridList(); } /// /// 关键词 /// /// /// private void txt_Key_EditValueChanged(object sender, EventArgs e) { RefreshGridList(); } /// /// 绘制行号 /// /// /// private void grv_List_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) { if (e.Info.IsRowIndicator && e.RowHandle > -1) { e.Info.DisplayText = (e.RowHandle + 1).ToString(); } } } }