using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Grid; using HL_FristAidPlatform_Public; using System; using System.Collections.Generic; using System.Data; using System.Drawing; namespace HL_FristAidPlatform_FollowUp { public partial class Form_FollowUpMain_ChestPain : XtraForm { #region 变量 /// /// 当前页 /// private int curPage = 1; /// /// 所有记录条数 /// public int totalNumber = 0; /// /// 每页大小 /// private int pageSize = 20; /// /// 病人GUID /// private string pGUID; /// /// guid集合 /// private List listGuid; #endregion #region 分页实现 private void userControlForPage_exportEvents(bool singlePage) { userControlForPage.exportEvents += ExportEvents; } private void userControlForPage_myPagerEvents(int curPage, int pageSize) { userControlForPage.myPagerEvents += MyPagerEvents; } private void MyPagerEvents(int curPage, int pageSize) { this.curPage = curPage; this.pageSize = pageSize; FillGridListCtrlQuery(curPage); } public void ExportEvents(bool singlePage)//单页,所有 { //导出GridControl代码写在这。 } /// /// 绑定数据源 /// /// private void FillGridListCtrlQuery(int curPage) { try { string Url = string.Empty; string startTime = dateEdit_Start.TimeValue; string endTime = dateEdit_End.TimeValue; string strParameter = ""; //没有所有院区权限 只获取当前院区数据 if (!PublicHelp.IsHaveAllDistrictRight(Information.User.ID)) { strParameter = Information.Hospital.GUID; } Url = string.Format("api/service/T_Service_FollowUp_ChestPain/GetModelByFollowUp/?key={0}&startTime={1}&endTime={2}&pageIndex={3}&pageSize={4}&systemModuleID={5}&state={6}&hospitalGuid={7}", textEdit_Key.Text.ToString().Trim(), startTime, endTime, curPage, pageSize, Information.SystemModuleInfo.ID, (int)Enumerate.EmergencyState.已转归, strParameter); listGuid = new List(); DataTable patientDT = DBHelpClass.Get(Url); gridControl_Patients.DataSource = patientDT; totalNumber = DBHelpClass.TotalNumber; userControlForPage.RefreshPager(pageSize, totalNumber, curPage);//更新分页控件显示。 } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定数据源:\r\n" + ex); } } #endregion public Form_FollowUpMain_ChestPain() { InitializeComponent(); } /// /// 窗体加载 /// /// /// private void Form_FollowUpMain_Load(object sender, EventArgs e) { dateEdit_Start.TimeValue = DateTime.Now.AddDays(-7).ToShortDateString() + " 00:00:00"; dateEdit_End.TimeValue = DateTime.Now.ToShortDateString() + " 23:59:59"; //查询 simpleButton_Search_Click(null, null); } /// /// 查询 /// /// /// private void simpleButton_Search_Click(object sender, EventArgs e) { FillGridListCtrlQuery(curPage); } /// /// 本月 /// /// /// private void simpleButton_ThisMonth_Click(object sender, EventArgs e) { dateEdit_Start.TimeValue = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.ToShortDateString(); dateEdit_End.TimeValue = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToShortDateString(); FillGridListCtrlQuery(curPage); } /// /// 本周 /// /// /// private void simpleButton_ThisWeek_Click(object sender, EventArgs e) { dateEdit_Start.TimeValue = DateTime.Now.AddDays(Convert.ToDouble((0 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString() + " 00:00:00"; dateEdit_End.TimeValue = DateTime.Now.AddDays(Convert.ToDouble((6 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString() + " 23:59:59"; FillGridListCtrlQuery(curPage); } /// /// 今天 /// /// /// private void simpleButton_ToDay_Click(object sender, EventArgs e) { dateEdit_Start.TimeValue = DateTime.Now.Date.ToShortDateString() + " 00:00:00"; dateEdit_End.TimeValue = DateTime.Now.Date.ToShortDateString() + " 23:59:59"; FillGridListCtrlQuery(curPage); } /// /// 全部 /// /// /// private void simpleButton_all_Click(object sender, EventArgs e) { dateEdit_Start.TimeValue = "1990-01-01 00:00:00"; dateEdit_End.TimeValue = DateTime.Now.Date.ToShortDateString() + " 23:59:59"; FillGridListCtrlQuery(curPage); } /// /// 列表双击事件 /// /// /// private void gridControl_Patients_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) { if (gridView_Patients.DataRowCount > 0) { int selectRow = gridView_Patients.GetSelectedRows()[0]; long PatientID = PublicClass.ToInt64(gridView_Patients.GetRowCellValue(selectRow, "ID").ToString(), 0); pGUID = gridView_Patients.GetRowCellValue(selectRow, "GUID").ToString(); if (PatientID > 0) { Form_FollowUpDetail_ChestPain detail = new Form_FollowUpDetail_ChestPain(pGUID); detail.Show(); } } } /// /// 新建随访计划 /// /// /// private void simpleButton_Schdul_Click(object sender, EventArgs e) { Form_FollowUpTemplate_ChestPain form_FollowUpTemplate = new Form_FollowUpTemplate_ChestPain(pGUID); form_FollowUpTemplate.Show(); } private void gridView_Patients_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { GridView View = sender as GridView; //随访状态 if (e.Column.FieldName == "FollowUpStatus") { var FollowUpStatus = e.CellValue; switch (FollowUpStatus) { case "0": e.Appearance.BackColor = Color.Red; e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255); break; case "1": e.Appearance.BackColor = Color.Green; e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255); break; default: break; } } if (e.Column.FieldName == "FollowUpDate") { var FollowUpDate = Convert.ToString(e.CellValue); if (!string.IsNullOrEmpty(FollowUpDate)) { if (DateTime.Now.Day == Convert.ToDateTime(FollowUpDate).Day) { e.Appearance.BackColor = Color.Red; e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255); } else { e.Appearance.BackColor = Color.Green; e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255); } } else { e.Appearance.BackColor = Color.Green; e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255); } } } private void gridView_Patients_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { GridView View = sender as GridView; //随访状态 if (e.Column.FieldName == "FollowUpDate") { var FollowUpDate = Convert.ToString(e.Value); e.DisplayText = FollowUpDate; } if (e.Column.FieldName == "FollowUpStatus") { var FollowUpStatus = Convert.ToString(e.Value); switch (FollowUpStatus) { case "0": e.DisplayText = "未随访"; break; case "1": e.DisplayText = "已随访"; break; default: break; } } } private void Form_FollowUpMain_ChestPain_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e) { this.Dispose(); } } }