天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.8 KiB

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.Windows.Forms;
using QMAPP.FJC.Entity;
using QMAPP.FJC.Entity.WarnManage;
using QMAPP.ServicesAgent;
using QMAPP.WinForm.Common;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMAPP.Entity;
namespace QMAPP.WinForm.Forms.EquipmentAlarm
{
/// <summary>
/// 模块编号:M16-3
/// 作 用:报警查询
/// 作 者:王庆男
/// 编写日期:2015年06月01日
///</summary>
public partial class EquipmentAlarmForm : Form
{
WarnInfo searchModel = new WarnInfo();//查询条件
public EquipmentAlarmForm()
{
InitializeComponent();
}
#region 窗体载入
private void Form_Load(object sender, EventArgs e)
{
#region 绑定下拉列表
BasicData basicData = new BasicData();
//初始化控件属性
this.DGView.AutoGenerateColumns = false;
//加载所有报警类别下拉列表
this.comType.DataSource = basicData.GetDictionaryList(EnumGeter.DictKind.WARNTYPE.ToString());
this.comType.DisplayMember = "VALUE";
this.comType.ValueMember = "KEY";
#endregion
//初始化分页
this.pager1.Init();
//加载默认查询条件
SetSearchModel();
BindGirdData();
}
#endregion
#region 绑定数据
private DataPage BindGirdData()
{
List<WarnInfo> recorders = null;//查询结果列表
DataPage dataPage = new DataPage();
//获取前台分页设置信息
dataPage = pager1.DataPage;
try
{
#region 服务查询
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<DataPage> result = agent.InvokeServiceFunction<DataResult<DataPage>>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_GetWarnInfoList.ToString(), searchModel, dataPage);
dataPage = result.Result;
recorders = JsonConvertHelper.GetDeserialize<List<WarnInfo>>(dataPage.Result.ToString());
#endregion
this.DGView.DataSource = recorders;
this.pager1.DataPage = dataPage;
}
catch (Exception ex)
{
throw ex;
}
return dataPage;
}
#endregion
/// <summary>
/// 分页事件
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
private DataPage pager1_EventPaging(Controls.EventPagingArg e)
{
return BindGirdData();
}
/// <summary>
/// 查询事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSearch_Click(object sender, EventArgs e)
{
SetSearchModel();
this.pager1.Init();
BindGirdData();
}
/// <summary>
/// 设置查询条件
/// </summary>
private void SetSearchModel()
{
searchModel = new WarnInfo();
//编码
if (string.IsNullOrEmpty(this.txtCode.Text.Trim()) == false)
{
searchModel.WARNCODE = this.txtCode.Text.Trim();
}
//类别
if (this.comType.SelectedValue != null && string.IsNullOrEmpty(this.comType.SelectedValue.ToString().Trim()) == false)
{
searchModel.WARNTYPE = this.comType.SelectedValue.ToString().Trim();
}
//开始时间
if (string.IsNullOrEmpty(this.dtpStart.Text.Trim()) == false)
{
searchModel.STARTCREATEDATE = Convert.ToDateTime(this.dtpStart.Text);
}
//结束时间
if (string.IsNullOrEmpty(this.dtpEnd.Text.Trim()) == false)
{
searchModel.ENDCREATEDATE = Convert.ToDateTime(this.dtpEnd.Text);
}
}
/// <summary>
/// 行序号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DG_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DGView.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGView.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
}
}