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

281 lines
10 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;
using QMAPP.FJC.Entity.ProduceManage;
namespace QMAPP.WinForm.Forms.WarehouseManage
{
/// <summary>
/// 模块编号:M13-4
/// 作 用:入库曹组
/// 作 者:王丹丹
/// 编写日期:2015年07月15日
///</summary>
public partial class InWarehouseForm : Form
{
Product searchModel = new Product();//查询条件
Product product = new Product();
Main main = new Main();
int isValidate = 0;//0:未校验 1:已校验
public InWarehouseForm()
{
InitializeComponent();
}
#region 窗体载入
private void Form_Load(object sender, EventArgs e)
{
//初始化控件属性
this.DGMendRecorder.AutoGenerateColumns = false;
//初始化分页
//this.pager1.Init();
//加载默认查询条件
SetSearchModel();
}
#endregion
#region 绑定数据
/// <summary>
/// 绑定数据列表
/// </summary>
/// <returns></returns>
private DataPage BindGirdData()
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
DataResult<Product> resultProduct = new DataResult<Product>();
DataResult<Main> resultMain = new DataResult<Main>();
List<Product> listProduct = new List<Product>();
List<Main> listMain = new List<Main>();
DataPage dataPage = new DataPage();
//获取前台分页设置信息
//dataPage = pager1.DataPage;
try
{
//获取零件信息
resultProduct = agent.InvokeServiceFunction<DataResult<Product>>(B9IPCService.InWarehouseBLL_GetProductInfo.ToString(), searchModel);
//本体
if (resultProduct.Result.PRODUCTTYPE == EnumGeter.ProductType.biaopi.GetHashCode().ToString() && resultProduct.Result.USINGSTATE == EnumGeter.USINGSTATE.USING.GetHashCode().ToString())
{
Main mainModel = new Main();
mainModel.EPIDERMISCODE = resultProduct.Result.PRODUCTCODE;
//获取本体信息
resultMain = agent.InvokeServiceFunction<DataResult<Main>>(B9IPCService.InWarehouseBLL_GetMainInfo.ToString(), mainModel);
if (!resultMain.IsSuccess)
{
MessageBox.Show(resultMain.Msg, resultMain.Msg, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
mainModel = resultMain.Result;
//绑定本体信息到列表中
listMain.Add(resultMain.Result);
this.DGMendRecorder.DataSource = listMain;
}
}
else
{
//绑定零件信息到列表中
listProduct.Add(resultProduct.Result);
this.DGMendRecorder.DataSource = listProduct;
}
}
catch (Exception ex)
{
throw ex;
}
return dataPage;
}
#endregion
#region 事件
/// <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)
{
isValidate = 0;
//设置查询条件
SetSearchModel();
//查询条件校验
bool issuccess = ExistSearchModel();
DataResult<Product> resultProduct = new DataResult<Product>();
DataResult<Main> resultMain = new DataResult<Main>();
//获取前台分页设置信息
//DataPage dataPage = pager1.DataPage;
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
List<Product> listProduct = new List<Product>();
List<Main> listMain = new List<Main>();
if (issuccess)
{
//this.pager1.Init();
//获取零件信息
resultProduct = agent.InvokeServiceFunction<DataResult<Product>>(B9IPCService.InWarehouseBLL_GetProductInfo.ToString(), searchModel);
if (!resultProduct.IsSuccess)
{
MessageBox.Show(resultProduct.Msg, resultProduct.Msg, MessageBoxButtons.OK, MessageBoxIcon.Warning);
isValidate = 0;
}
else
{
product = resultProduct.Result;
//本体
if (product.PRODUCTTYPE == EnumGeter.ProductType.biaopi.GetHashCode().ToString() && product.USINGSTATE == EnumGeter.USINGSTATE.USING.GetHashCode().ToString())
{
main.EPIDERMISCODE = product.PRODUCTCODE;
//获取本体信息
resultMain = agent.InvokeServiceFunction<DataResult<Main>>(B9IPCService.InWarehouseBLL_GetMainInfo.ToString(), main);
if (!resultMain.IsSuccess)
{
MessageBox.Show(resultMain.Msg, resultMain.Msg, MessageBoxButtons.OK, MessageBoxIcon.Warning);
isValidate = 0;
}
else
{
main = resultMain.Result;
//绑定本体信息到列表中
listMain.Add(resultMain.Result);
this.DGMendRecorder.DataSource = listMain;
isValidate = 1;
}
}
else
{
//绑定零件信息到列表中
listProduct.Add(resultProduct.Result);
this.DGMendRecorder.DataSource = listProduct;
isValidate = 1;
}
}
}
}
/// <summary>
/// 入库
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbInWarehouse_Click(object sender, EventArgs e)
{
QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
//入库校验
bool issuccess = ExistOutWarehouse();
DataResult result = new DataResult();
if (issuccess)
{
if (product.PRODUCTTYPE == EnumGeter.ProductType.biaopi.GetHashCode().ToString() && product.USINGSTATE == EnumGeter.USINGSTATE.USING.GetHashCode().ToString())
{
//本体
result = agent.InvokeServiceFunction<DataResult>(B9IPCService.InWarehouseBLL_MainOutWarehouse.ToString(), main);
}
else
{
//零件
result = agent.InvokeServiceFunction<DataResult>(B9IPCService.InWarehouseBLL_ProductOutWarehouse.ToString(), product);
}
MessageBox.Show(result.Msg, result.Msg, MessageBoxButtons.OK, MessageBoxIcon.Warning);
BindGirdData();
isValidate = 0;
this.txtPRODUCTCODE.Text = "";
}
}
#endregion
#region 设置查询条件
/// <summary>
/// 设置查询条件
/// </summary>
private void SetSearchModel()
{
searchModel = new Product();
//条码
if (string.IsNullOrEmpty(this.txtPRODUCTCODE.Text.Trim()) == false)
{
searchModel.PRODUCTCODE = this.txtPRODUCTCODE.Text.Trim();
}
}
#endregion
/// <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.DGMendRecorder.RowHeadersWidth - 4, e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), new Font("宋体", 12, FontStyle.Bold), rectangle, this.DGMendRecorder.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
#region 查询条件校验
/// <summary>
/// 查询条件校验
/// </summary>
private bool ExistSearchModel()
{
//条码
if (string.IsNullOrEmpty(this.txtPRODUCTCODE.Text.Trim()))
{
MessageBox.Show(Resource1.ProductCodeNullValidate, Resource1.ProductCodeNullValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
return true;
}
#endregion
#region 入库校验
/// <summary>
/// 入库校验
/// </summary>
private bool ExistOutWarehouse()
{
//条码
if (string.IsNullOrEmpty(this.txtPRODUCTCODE.Text.Trim()))
{
MessageBox.Show(Resource1.ProductCodeNullValidate, Resource1.ProductCodeNullValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
//条码是否已验证
if (isValidate==0)
{
MessageBox.Show(Resource1.ProductCodeValidate, Resource1.ProductCodeValidate, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
return true;
}
#endregion
}
}