天津投入产出系统后端
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.

172 lines
5.9 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QMAPP.WinForm.Common;
using QMAPP.FJC.Entity.Basic;
using QMAPP.ServicesAgent;
using QMFrameWork.Data;
using QMAPP.FJC.Entity.Operation;
using QMFrameWork.Common.Serialization;
using QMAPP.Entity;
namespace QMAPP.WinForm.Forms.Operation
{
/// <summary>
/// 描述:加工查询
/// 作者:单雨春
/// 时间:2015年6月5日10:41:15
/// </summary>
public partial class MainOperationSearchForm : Form
{
private ServiceAgent wcfAgent = null;
private MachineInfo _machine = null;
private ProcessSet _pSet = null;
public MainOperationSearchForm()
{
InitializeComponent();
if (ClientContext.MachineInfo != null)
{
_machine = ClientContext.MachineInfo;
}
Init();
}
public MainOperationSearchForm(MachineInfo machine)
{
InitializeComponent();
_machine = machine;
Init();
}
public MainOperationSearchForm(MachineInfo machine,ProcessSet pSet)
{
InitializeComponent();
_machine = machine;
_pSet = pSet;
Init();
}
private void Init()
{
wcfAgent = ClientContext.GetServiceAgent();
BasicData baseData = new BasicData();
#region 绑定班次
cbxProduceShift.DataSource = baseData.GetProduceShiftComboxSource(new FJC.Entity.Basic.ProduceShift(), true);
#endregion
this.dateOpeStart.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
this.dateOpeEnd.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
BindDataGrid();
}
#region 绑定数据
/// <summary>
/// 绑定数据
/// </summary>
private void BindDataGrid()
{
var dataResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>(QMAPP.ServicesAgent.B9BasicService.MainOperationBLL_GetListWithParameter.ToString(),
new MainOperation
{
PROCESSTYPE =_pSet==null? _machine.PROCESSTYPE:_pSet.PROCESSTYPE,
PRODUCTTYPE =_pSet==null?"":_pSet.PRODUCTTYPE,
PRODUCELINE =_machine.PRODUCELINE,
MACHINECODDE =_machine.MACHINECODDE,
PRODUCESHIFTTCODE = cbxProduceShift.SelectedValue.ToString(),
PRODUCTCODE = txtProductCode.Text,
DATEOPESTART = String.IsNullOrEmpty(dateOpeStart.Text.Trim()) ? DateTime.MinValue : Convert.ToDateTime(dateOpeStart.Text.Trim()),
DATEOPEEND = String.IsNullOrEmpty(dateOpeEnd.Text.Trim()) ? DateTime.MinValue : Convert.ToDateTime(dateOpeEnd.Text.Trim())
},
pager1.DataPage);
if (!dataResult.IsSuccess)
{
MessageBox.Show(dataResult.Msg);
}
DGData.DataSource = JsonConvertHelper.GetDeserialize<DataTable>(dataResult.Result.Result.ToString());
//设置数值型局右显示
foreach (var item in DGData.Columns.Cast<DataGridViewColumn>())
{
if (item.ValueType == typeof(double) ||
item.ValueType == typeof(Int16) ||
item.ValueType == typeof(Int32) ||
item.ValueType == typeof(Int64))
{
item.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
}
}
pager1.DataPage = dataResult.Result;
}
#endregion
#region 查询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSearch_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(dateOpeStart.Text.Trim()) &&
!String.IsNullOrEmpty(dateOpeEnd.Text.Trim()) &&
Convert.ToDateTime(dateOpeStart.Text.Trim()) > Convert.ToDateTime(dateOpeEnd.Text.Trim()))
{
MessageBox.Show(Resource1.OpeateDateScope);
return;
}
pager1.DataPage.PageIndex = 1;
BindDataGrid();
}
#endregion
#region 窗体加载事件
private void MainOperationSearchForm_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
}
#endregion
#region 设置序号
private void DGData_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DGData.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGData.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
#endregion
private DataPage pager1_EventPaging(Controls.EventPagingArg e)
{
BindDataGrid();
return pager1.DataPage;
}
private void tbtnSearch_Click(object sender, EventArgs e)
{
Form f = Application.OpenForms["OperationForm"]; //查找是否打开过Form1窗体
if (f == null) //没打开过
{
OperationForm form = new OperationForm();
form.MdiParent = this.ParentForm;
form.Show(); //重新new一个Show出来
}
else
{
f.WindowState = FormWindowState.Normal;
f.Focus(); //打开过就让其获得焦点
}
}
}
}