using System; using System.Collections.Generic; using System.Configuration; using System.Drawing; using System.Windows.Forms; using QM.Common; using QMAPP.FJC.Entity; using QMAPP.FJC.Entity.SendPlan; using QMAPP.FJC.Entity.Operation; using QMAPP.ServicesAgent; using QMAPP.WinForm.Common; using QMFrameWork.Common.Serialization; using QMFrameWork.Data; namespace QMAPP.WinForm.Forms.SendPlan { /// /// 原材料投料 /// public partial class SendPlanSearchForm : Form { SendPlanInfo searchModel = new SendPlanInfo();//查询条件 public SendPlanSearchForm() { InitializeComponent(); } #region 窗体载入 private void Form_Load(object sender, EventArgs e) { //初始化窗口最大化 this.WindowState = FormWindowState.Maximized; BasicData basicData = new BasicData(); //初始化控件属性 this.DGView.AutoGenerateColumns = false; //初始化条件 this.dtpCreateUserStart.ValueX = DateTime.Now.AddDays(-10); this.dtpCreateUserEnd.ValueX = DateTime.Now; //初始化分页 this.pager1.Init(); //加载默认查询条件 SetSearchModel(); BindGirdData(); } #endregion #region 绑定数据 private DataPage BindGirdData() { List recorders = null;//查询结果列表 DataPage dataPage = new DataPage(); //获取前台分页设置信息 dataPage = pager1.DataPage; try { QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); dataPage = agent.InvokeServiceFunction(B9IPCService.SendPlanInfoBLL_GetList.ToString(), searchModel, dataPage); recorders = JsonConvertHelper.GetDeserialize>(dataPage.Result.ToString()); this.DGView.DataSource = recorders; this.pager1.DataPage = dataPage; } catch (Exception ex) { throw ex; } return dataPage; } #endregion /// /// 分页事件 /// /// /// private DataPage pager1_EventPaging(Controls.EventPagingArg e) { return BindGirdData(); } /// /// 查询事件 /// /// /// private void tsbSearch_Click(object sender, EventArgs e) { SetSearchModel(); this.pager1.Init(); BindGirdData(); } /// /// 设置查询条件 /// private void SetSearchModel() { searchModel = new SendPlanInfo(); searchModel.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString(); if (string.IsNullOrEmpty(this.txtCode.Text.Trim()) == false) { searchModel.SENDCODE = this.txtCode.Text.Trim(); } if (string.IsNullOrEmpty(this.dtpCreateUserStart.Text.Trim()) == false) { searchModel.CreateDateStart = Convert.ToDateTime(this.dtpCreateUserStart.Text).ToString("yyyy-MM-dd").Trim(); } if (string.IsNullOrEmpty(this.dtpCreateUserEnd.Text.Trim()) == false) { searchModel.CreateDateEnd = Convert.ToDateTime(this.dtpCreateUserEnd.Text).AddDays(1).ToString("yyyy-MM-dd").Trim(); } } /// /// 打开新建 /// /// /// private void tsbAdd_Click(object sender, EventArgs e) { SendPlanPrintForm editForm = new SendPlanPrintForm(); DialogResult result = editForm.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { this.pager1.Init(); BindGirdData(); } } /// /// 打开补打 /// /// /// private void tsbEdit_Click(object sender, EventArgs e) { if (this.DGView.SelectedRows.Count > 0) { string selectKey = this.DGView.SelectedRows[0].Cells["SENDCODE"].Value.ToString(); SendPlanSearchEditForm editForm = new SendPlanSearchEditForm(selectKey); DialogResult result = editForm.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { this.pager1.Init(); BindGirdData(); } } } /// /// 行序号 /// /// /// 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); } } }