using System; using System.Collections.Generic; using System.Configuration; using System.Drawing; using System.Windows.Forms; using QMAPP.FJC.Entity; using QMAPP.FJC.Entity.Injection; using QMAPP.FJC.Entity.Operation; using QMAPP.ServicesAgent; using QMAPP.WinForm.Common; using QMFrameWork.Common.Serialization; using QMFrameWork.Data; using QMAPP.Entity; using QMAPP.FJC.Entity.ProduceManage; using QMAPP.FJC.Entity.FIS; namespace QMAPP.WinForm.Forms.InformationSearch { /// /// 模块编号:M15-1 /// 作 用:FIS M100生产信息查询 /// 作 者:王丹丹 /// 编写日期:2015年07月10日 /// public partial class FisM100ListForm : Form { FISInfo searchModel = new FISInfo();//查询条件 public FisM100ListForm() { InitializeComponent(); } #region 窗体载入 private void Form_Load(object sender, EventArgs e) { //初始化控件属性 this.DGFisInfo.AutoGenerateColumns = false; //初始化分页 this.pager1.Init(); //加载默认查询条件 SetSearchModel(); BindGirdData(); } #endregion #region 绑定数据 /// /// 绑定数据列表 /// /// private DataPage BindGirdData() { List fisInfoList = null;//查询结果列表 DataPage dataPage = new DataPage(); DataResult result = new DataResult(); //获取前台分页设置信息 dataPage = pager1.DataPage; try { #region 服务查询 QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); result = agent.InvokeServiceFunction>(B9IPCService.FISInfoBLL_GetList.ToString(), searchModel, dataPage); fisInfoList = JsonConvertHelper.GetDeserialize>(result.Result.Result.ToString()); #endregion this.DGFisInfo.DataSource = fisInfoList; this.pager1.DataPage = result.Result; } catch (Exception ex) { throw ex; } return dataPage; } #endregion #region 事件 /// /// 分页事件 /// /// /// private DataPage pager1_EventPaging(Controls.EventPagingArg e) { return BindGirdData(); } /// /// 查询事件 /// /// /// private void tsbSearch_Click(object sender, EventArgs e) { bool issuccess = ExistSearchModel(); if (issuccess) { SetSearchModel(); this.pager1.Init(); BindGirdData(); } } #endregion #region 设置查询条件 /// /// 设置查询条件 /// private void SetSearchModel() { searchModel = new FISInfo(); //searchModel.MACHINETYPE = EnumGeter.MACHINETYPE.tangsu.GetHashCode().ToString();//默认条件 //上线开始时间 if (string.IsNullOrEmpty(this.dtpONLINETIMESTART.Text.Trim()) == false) { searchModel.ONLINETIMESTART = Convert.ToDateTime(this.dtpONLINETIMESTART.Text).ToString("yyyy-MM-dd") + " 00:00:00"; } //上线结束时间 if (string.IsNullOrEmpty(this.dtpONLINETIMEEND.Text.Trim()) == false) { searchModel.ONLINETIMEEND = Convert.ToDateTime(this.dtpONLINETIMEEND.Text).ToString("yyyy-MM-dd") + " 23:59:59"; } } #endregion #region 校验查询条件 /// /// 校验查询条件 /// private bool ExistSearchModel() { //操作开始时间 if (!string.IsNullOrEmpty(this.dtpONLINETIMESTART.Text.Trim()) && !string.IsNullOrEmpty(this.dtpONLINETIMEEND.Text.Trim())) { DateTime startTime = Convert.ToDateTime(this.dtpONLINETIMESTART.Text); DateTime endTime = Convert.ToDateTime(this.dtpONLINETIMEEND.Text); if (startTime > endTime) { MessageBox.Show(Resource1.DateTimeValidate, Resource1.DateTimeValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } } return true; } #endregion /// /// 行序号 /// /// /// private void DG_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DGFisInfo.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGFisInfo.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); } } }