StableVersion4.3/HL_FristAidPlatform_FollowUp/Form_FollowUpMain.cs

276 lines
9.8 KiB
C#
Raw Permalink Normal View History

2024-03-11 09:47:34 +08:00
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 : XtraForm
{
#region 变量
/// <summary>
/// 当前页
/// </summary>
private int curPage = 1;
/// <summary>
/// 所有记录条数
/// </summary>
public int totalNumber = 0;
/// <summary>
/// 每页大小
/// </summary>
private int pageSize = 20;
/// <summary>
/// 病人GUID
/// </summary>
private string pGUID;
/// <summary>
/// guid集合
/// </summary>
private List<string> 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代码写在这。
}
/// <summary>
/// 绑定数据源
/// </summary>
/// <returns></returns>
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/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<string>();
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()
{
InitializeComponent();
}
/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void simpleButton_Search_Click(object sender, EventArgs e)
{
FillGridListCtrlQuery(curPage);
}
/// <summary>
/// 本月
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 本周
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 今天
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 全部
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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);
}
/// <summary>
/// 列表双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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 detail = new Form_FollowUpDetail(pGUID);
detail.Show();
}
}
}
/// <summary>
/// 新建随访计划
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
}
}
}
}