using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using QMAPP.WinForm.Common;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
namespace QMAPP.WinForm.Forms.ProductIn
{
///
/// 作 用:入库
/// 作 者:周晓东
/// 编写日期:20180404
///
public partial class ProductInForm : Form
{
FJC.Entity.ProductIn.ProductIn searchModel = new FJC.Entity.ProductIn.ProductIn();//查询条件
public ProductInForm()
{
InitializeComponent();
}
#region 窗体载入
private void Form_Load(object sender, EventArgs e)
{
//初始化控件属性
this.DGView.AutoGenerateColumns = false;
//初始化分页
this.pager1.Init();
//加载下拉框
BasicData basicData = new BasicData();
//入库类型
this.comINTTYPE.DataSource = basicData.GetDictionaryList("INTTYPE");
this.comINTTYPE.DisplayMember = "value";
this.comINTTYPE.ValueMember = "key";
//加载默认查询条件
SetSearchModel();
BindGirdData();
}
#endregion
#region 绑定数据
private DataPage BindGirdData()
{
List recorders = null;//查询结果列表
DataPage dataPage = new DataPage();
//获取前台分页设置信息
dataPage = pager1.DataPage;
try
{
#region 服务查询
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
dataPage = agent.InvokeServiceFunction("ProductInBLL_GetList", searchModel, dataPage);
recorders = JsonConvertHelper.GetDeserialize>(dataPage.Result.ToString());
#endregion
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 FJC.Entity.ProductIn.ProductIn();
//条码
if (string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) == false)
{
searchModel.PRODUCTCODE = this.txtProductCode.Text.Trim();
}
//入库类型
if (this.comINTTYPE.SelectedValue != null && string.IsNullOrEmpty(this.comINTTYPE.SelectedValue.ToString().Trim()) == false)
{
searchModel.INTTYPE = this.comINTTYPE.SelectedValue.ToString().Trim();
}
//操作开始时间
if (string.IsNullOrEmpty(this.dtpCREATEDATESTART.Text.Trim()) == false)
{
searchModel.CREATEDATESTART = Convert.ToDateTime((this.dtpCREATEDATESTART.Value).ToString("yyyy-MM-dd") + " 00:00:00");
}
//操作结束时间
if (string.IsNullOrEmpty(this.dtpCREATEDATEEND.Text.Trim()) == false)
{
searchModel.CREATEDATEEND = Convert.ToDateTime((this.dtpCREATEDATEEND.Value).ToString("yyyy-MM-dd") + " 23:59:59");
}
}
///
/// 入库
///
///
///
private void tsbAdd_Click(object sender, EventArgs e)
{
//ProductInSendCodeForm editForm = new ProductInSendCodeForm();
//DialogResult result = editForm.ShowDialog();
//if (result == System.Windows.Forms.DialogResult.OK)//判断是否投料窗口已做操作
//{
// this.pager1.Init();
// BindGirdData();
//}
var form = new ProductInSendCodeForm();
form.StartPosition = FormStartPosition.CenterScreen;
form.ShowDialog();
this.pager1.Init();
BindGirdData();
}
// 行序号
private void DGView_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);
}
}
}