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

216 lines
7.0 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;
using QMFrameWork.Data;
using QMFrameWork.Common.Serialization;
using QMAPP.FJC.Entity.Operation;
using QMAPP.KB.Entity;
using QMAPP.ServicesAgent;
namespace QMAPP.WinForm.Forms.Injection
{
public partial class InjectionCheckListForm : Form
{
InjectionCheck searchModel;
public InjectionCheckListForm()
{
InitializeComponent();
}
private void tsbAdd_Click(object sender, EventArgs e)
{
InjectionCheckForm editForm = new InjectionCheckForm();
editForm.ShowDialog();
DataResult result = SetSearchModel();
if (result.IsSuccess == false)
{
MessageBox.Show("请输入正确的投料对比时间!");
return;
}
else
{
BindGirdData();
dataGridView1.ClearSelection();
}
}
private void btnScarp_Click(object sender, EventArgs e)
{
if (this.dataGridView1.SelectedRows.Count <= 0)
return;
if (MessageBox.Show(Resource1.ConfirmDelete, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) != DialogResult.OK)
return;
string pid = this.dataGridView1.SelectedRows[0].Cells["id"].Value.ToString();
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult result = agent.InvokeServiceFunction<DataResult>(B9IPCService.InjectionCheckBLL_Delete.ToString(), pid);
if (result.IsSuccess == true)
{
DataResult validresult = SetSearchModel();
if (validresult.IsSuccess == false)
{
MessageBox.Show("请输入正确的投料对比时间!");
return;
}
else
{
BindGirdData();
dataGridView1.ClearSelection();
}
}
else
{
MessageBox.Show("删除失败!");
return;
}
}
private void tsbSearch_Click(object sender, EventArgs e)
{
DataResult result = SetSearchModel();
if (result.IsSuccess == false)
{
MessageBox.Show("请输入正确的投料对比时间!");
return;
}
else
{
BindGirdData();
dataGridView1.ClearSelection();
}
}
private void InjectionCheckListForm_Load(object sender, EventArgs e)
{
DateTime dtStart = DateTime.Now;
dpOpeStart.Value = dtStart;
dpOpeEnd.Value = dtStart.AddDays(1);
#region 绑定下拉列表
BasicData basicData = new BasicData();
//初始化控件属性
this.dataGridView1.AutoGenerateColumns = false;
//加载注塑设备列表
this.comMachine.DataSource = basicData.GetMachineInfoList(new string[] { EnumGeter.ProcessType_M.Injection.GetHashCode().ToString() }, true);
this.comMachine.DisplayMember = "MACHINENAME";
this.comMachine.ValueMember = "MACHINECODDE";
//产品类型
this.comProType.DataSource = basicData.GetProductBasicList(EnumGeter.PRODUCTMAINTYPE.zhusu.GetHashCode().ToString(), true);
this.comProType.DisplayMember = "PRODUCTNAME";
this.comProType.ValueMember = "PRODUCTTYPE";
#endregion
//初始化分页
this.pager1.Init();
//加载默认查询条件
DataResult result = SetSearchModel();
if (result.IsSuccess != false)
{
BindGirdData();
dataGridView1.ClearSelection();
}
}
#region 绑定数据
private DataPage BindGirdData()
{
List<InjectionCheck> recorders = null;//查询结果列表
DataPage dataPage = new DataPage();
//获取前台分页设置信息
dataPage = pager1.DataPage;
try
{
#region 服务查询
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
dataPage = agent.InvokeServiceFunction<DataPage>(B9IPCService.InjectionCheckBLL_GetList.ToString(), searchModel, dataPage);
recorders = JsonConvertHelper.GetDeserialize<List<InjectionCheck>>(dataPage.Result.ToString());
#endregion
this.dataGridView1.DataSource = recorders;
this.pager1.DataPage = dataPage;
}
catch (Exception ex)
{
throw ex;
}
return dataPage;
}
#endregion
/// <summary>
/// 设置查询条件
/// </summary>
private DataResult SetSearchModel()
{
DataResult result = new DataResult();
result.IsSuccess = true;
searchModel = new InjectionCheck();
searchModel.CREATEDATESTART = Convert.ToDateTime(dpOpeStart.Value.ToString("yyyy-MM-dd") + " 00:00:00");
searchModel.CREATEDATEEND = Convert.ToDateTime(dpOpeEnd.Value.ToString("yyyy-MM-dd") + " 00:00:00");
//设备
if (this.comMachine.SelectedValue != null && string.IsNullOrEmpty(this.comMachine.SelectedValue.ToString().Trim()) == false)
{
searchModel.MACHINECODDE = this.comMachine.SelectedValue.ToString().Trim();
}
//条码
if (string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) == false)
{
searchModel.PRODUCTCODE = this.txtProductCode.Text.Trim();
}
//零件类别
if (this.comProType.SelectedValue != null && string.IsNullOrEmpty(this.comProType.SelectedValue.ToString()) == false)
{
searchModel.PRODUCTTYPE = this.comProType.SelectedValue.ToString();
}
return result;
}
private void panelSearchTitle_Paint(object sender, PaintEventArgs e)
{
}
private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
if (e.RowIndex > dataGridView1.Rows.Count - 1)
return;
DataGridViewRow dgr = dataGridView1.Rows[e.RowIndex];
try
{
if ((bool)dgr.Cells["ISINJECT"].Value == false)
{
dgr.DefaultCellStyle.BackColor = Color.Red;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}