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

299 lines
11 KiB

3 years ago
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;
using QMAPP.MD.Entity.TianJin;
namespace QMAPP.WinForm.Forms.TianJin
{
/// <summary>
/// 模块编号:M13-3
/// 作 用:出库操作
/// 作 者:王丹丹
/// 编写日期:2015年07月13日
///</summary>
public partial class TJOutWarehouseForm : Form
{
Storage searchModel = new Storage();//查询条件
Storage product = new Storage();
Main main = new Main();
int isValidate = 0;//0:未校验 1:已校验
public TJOutWarehouseForm()
{
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<Storage> resultProduct = new DataResult<Storage>();
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
{
//获取零件信息
var result = agent.InvokeServiceFunction<DataResult<DataPage>>("StorageBLL_GetList", searchModel, dataPage);
//本体
//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.OutWarehouseBLL_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.OutWarehouseBLL_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.OutWarehouseBLL_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 tsbOutWarehouse_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.OutWarehouseBLL_MainOutWarehouse.ToString(), main);
//}
//else
//{
// //零件
// result = agent.InvokeServiceFunction<DataResult>(B9IPCService.OutWarehouseBLL_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 Storage();
//条码
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.InStorageType = this.comINTTYPE.SelectedValue.ToString().Trim();
}
//操作开始时间
if (string.IsNullOrEmpty(this.dtpCREATEDATESTART.Text.Trim()) == false)
{
searchModel.BeginTime = Convert.ToDateTime((this.dtpCREATEDATESTART.Value).ToString("yyyy-MM-dd") + " 00:00:00");
}
//操作结束时间
if (string.IsNullOrEmpty(this.dtpCREATEDATEEND.Text.Trim()) == false)
{
searchModel.EndTime = Convert.ToDateTime((this.dtpCREATEDATEEND.Value).ToString("yyyy-MM-dd") + " 23:59:59");
}
}
#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
}
}