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

234 lines
9.2 KiB

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;
namespace QMAPP.WinForm.Forms.Injection
{
/// <summary>
/// 模块编号:M11-1
/// 作 用:投料记录
/// 作 者:王庆男
/// 编写日期:2015年05月26日
///</summary>
public partial class SlushMoldingForm : Form
{
InjectionRecorder searchModel = new InjectionRecorder();//查询条件
public SlushMoldingForm()
{
InitializeComponent();
}
#region 窗体载入
private void Form_Load(object sender, EventArgs e)
{
//初始化控件属性
this.DGSlushMolding.AutoGenerateColumns = false;
#region 绑定下拉列表
BasicData basicData = new BasicData();
//加载搪塑设备列表
this.comSlushMachine.DataSource = basicData.GetMachineInfoList(new string[] { EnumGeter.ProcessType_M.Slush.GetHashCode().ToString() }, true);
this.comSlushMachine.DisplayMember = "MACHINENAME";
this.comSlushMachine.ValueMember = "MACHINECODDE";
//加载原材料列表
this.comMaterialNo.DataSource = basicData.GetMaterielInfoList("RAW_SLUSH", true);
this.comMaterialNo.DisplayMember = "MATERIAL_NAME";
this.comMaterialNo.ValueMember = "MATERIAL_CODE";
//加载操作人
this.comOpereator.DataSource = basicData.GetOperatorInfoList(EnumGeter.ProcessType.tangsu.GetHashCode().ToString(), true); ;
this.comOpereator.DisplayMember = "OPERATOR";
this.comOpereator.ValueMember = "OPERATORCODE";
//初始化条件
this.dtpCreateUserStart.ValueX = DateTime.Now.AddDays(-10);
this.dtpCreateUserEnd.ValueX = DateTime.Now;
#endregion
//初始化分页
this.pager1.Init();
//加载默认查询条件
SetSearchModel();
BindGirdData();
}
#endregion
#region 绑定数据
private DataPage BindGirdData()
{
List<InjectionRecorder> recorders = null;//查询结果列表
DataPage dataPage = new DataPage();
//获取前台分页设置信息
dataPage = pager1.DataPage;
try
{
#region 服务查询
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
dataPage = agent.InvokeServiceFunction<DataPage>(B9BasicService.InjectionRecorderBLL_GetList.ToString(), searchModel, dataPage);
recorders = JsonConvertHelper.GetDeserialize<List<InjectionRecorder>>(dataPage.Result.ToString());
foreach (InjectionRecorder inj in recorders)
{
inj.INJECTIONTERMINALNAME = inj.INJECTIONINDEX.ToString() + "-" + inj.INJECTIONTERMINAL.ToString();
}
#endregion
this.DGSlushMolding.DataSource = recorders;
this.pager1.DataPage = dataPage;
}
catch (Exception ex)
{
throw ex;
}
return dataPage;
}
#endregion
/// <summary>
/// 分页事件
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
private DataPage pager1_EventPaging(Controls.EventPagingArg e)
{
return BindGirdData();
}
/// <summary>
/// 查询事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbSearch_Click(object sender, EventArgs e)
{
SetSearchModel();
this.pager1.Init();
BindGirdData();
}
/// <summary>
/// 设置查询条件
/// </summary>
private void SetSearchModel()
{
searchModel = new InjectionRecorder();
searchModel.MACHINETYPE = EnumGeter.MACHINETYPE.tangsu.GetHashCode().ToString();//默认条件
//搪塑设备类别
if (this.comSlushMachine.SelectedValue != null && string.IsNullOrEmpty(this.comSlushMachine.SelectedValue.ToString().Trim()) == false)
{
searchModel.MACHINECODDE = this.comSlushMachine.SelectedValue.ToString().Trim();
}
//物料码
if (this.comMaterialNo.SelectedValue != null && string.IsNullOrEmpty(this.comMaterialNo.SelectedValue.ToString().Trim()) == false)
{
searchModel.MATERIALCODE = this.comMaterialNo.SelectedValue.ToString().Trim();
}
//批次
if (string.IsNullOrEmpty(this.txtBatch.Text.Trim()) == false)
{
searchModel.MATERIALBATCH = this.txtBatch.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();
}
//操作人
if (this.comOpereator.SelectedValue != null && string.IsNullOrEmpty(this.comOpereator.SelectedValue.ToString()) == false)
{
searchModel.CREATEUSER = this.comOpereator.SelectedValue.ToString();
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbDelete_Click(object sender, EventArgs e)
{
if (this.DGSlushMolding.SelectedRows.Count <= 0)
return;
if (MessageBox.Show(Resource1.ConfirmDelete, Resource1.ConfirmTitle, MessageBoxButtons.OKCancel) != DialogResult.OK)
return;
#region 执行删除
string selectKey = this.DGSlushMolding.SelectedRows[0].Cells["Pid"].Value.ToString();
//删除校验判断该投料批次号是否已经生产出产品,如果已生产出产品则不允许删除,如果不允许则弹出提示'该批次号物料已使用,不能删除!'
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<int> result = agent.InvokeServiceFunction<DataResult<int>>(B9BasicService.InjectionRecorderBLL_DeleteSingle.ToString(), selectKey);
MessageBox.Show(result.Msg);
if (result.IsSuccess)
{
BindGirdData();
}
#endregion
}
/// <summary>
/// 打开投料
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbAdd_Click(object sender, EventArgs e)
{
SlushMoldingEditForm editForm = new SlushMoldingEditForm();
DialogResult result = editForm.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)//判断是否投料窗口已做操作
{
this.pager1.Init();
BindGirdData();
}
}
/// <summary>
/// 打开编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbEdit_Click(object sender, EventArgs e)
{
if (this.DGSlushMolding.SelectedRows.Count > 0)
{
string selectKey = this.DGSlushMolding.SelectedRows[0].Cells["Pid"].Value.ToString();
SlushMoldingEditForm editForm = new SlushMoldingEditForm(selectKey);
DialogResult result = editForm.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)//判断是否投料窗口已做操作
{
this.pager1.Init();
BindGirdData();
}
}
}
/// <summary>
/// 行序号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DG_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DGSlushMolding.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGSlushMolding.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
private void txtBatch_DoubleClick(object sender, EventArgs e)
{
//Common.TouchKey key = new Common.TouchKey((TextBox)sender);
}
}
}