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 { /// /// 模块编号:M13-3 /// 作 用:出库操作 /// 作 者:王丹丹 /// 编写日期:2015年07月13日 /// public partial class OutWarehouseForm : Form { Product searchModel = new Product();//查询条件 Product product = new Product(); Main main = new Main(); int isValidate = 0;//0:未校验 1:已校验 public OutWarehouseForm() { InitializeComponent(); } #region 窗体载入 private void Form_Load(object sender, EventArgs e) { //初始化控件属性 this.DGMendRecorder.AutoGenerateColumns = false; //初始化分页 //this.pager1.Init(); //加载默认查询条件 SetSearchModel(); } #endregion #region 绑定数据 /// /// 绑定数据列表 /// /// private DataPage BindGirdData() { QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataResult resultProduct = new DataResult(); DataResult
resultMain = new DataResult
(); List listProduct = new List(); List
listMain = new List
(); DataPage dataPage = new DataPage(); //获取前台分页设置信息 //dataPage = pager1.DataPage; try { //获取零件信息 resultProduct = agent.InvokeServiceFunction>(B9IPCService.OutWarehouseBLL_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>(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 事件 /// /// 分页事件 /// /// /// private DataPage pager1_EventPaging(Controls.EventPagingArg e) { return BindGirdData(); } /// /// 查询事件 /// /// /// private void tsbSearch_Click(object sender, EventArgs e) { isValidate = 0; //设置查询条件 SetSearchModel(); //查询条件校验 bool issuccess = ExistSearchModel(); DataResult resultProduct = new DataResult(); DataResult
resultMain = new DataResult
(); //获取前台分页设置信息 //DataPage dataPage = pager1.DataPage; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); List listProduct = new List(); List
listMain = new List
(); if (issuccess) { //this.pager1.Init(); //获取零件信息 resultProduct = agent.InvokeServiceFunction>(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>(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; } } } } /// /// 出库 /// /// /// 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(B9IPCService.OutWarehouseBLL_MainOutWarehouse.ToString(), main); } else { //零件 result = agent.InvokeServiceFunction(B9IPCService.OutWarehouseBLL_ProductOutWarehouse.ToString(), product); } MessageBox.Show(result.Msg, result.Msg, MessageBoxButtons.OK, MessageBoxIcon.Warning); BindGirdData(); isValidate = 0; this.txtPRODUCTCODE.Text = ""; } } #endregion #region 设置查询条件 /// /// 设置查询条件 /// private void SetSearchModel() { searchModel = new Product(); //条码 if (string.IsNullOrEmpty(this.txtPRODUCTCODE.Text.Trim()) == false) { searchModel.PRODUCTCODE = this.txtPRODUCTCODE.Text.Trim(); } } #endregion /// /// 行序号 /// /// /// 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 查询条件校验 /// /// 查询条件校验 /// 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 出库校验 /// /// 出库校验 /// 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 } }