using System; using System.Collections.Generic; using System.Linq; using System.Text; using QMFrameWork.Data; using QMAPP.FJC.Entity.Operation; using QMAPP.FJC.DAL.Operation; using QMAPP.FJC.BLL.Dict; using QMAPP.BLL; using QMAPP.Entity; using QMAPP.FJC.Entity; using QMFrameWork.Log; using System.Data; namespace QMAPP.FJC.BLL.Operation { public class ProductOutBLL : BaseBLL { #region 获取列表 /// /// 获取列表 /// /// 条件 /// 数据页 /// 数据页 public DataResult GetInfoList(ProductOut condition, DataPage page) { DataResult result = new DataResult(); try { DataPage dataPage = new ProductOutDAL().GetList(condition, page); List list = dataPage.Result as List; #region 显示类型 //处理字典信息 DictManageBLL dictOUTREASON = new DictManageBLL(DictKind.OUTREASON); foreach (var info in list) { info.OUTREASON = dictOUTREASON.GetDictValue(info.OUTREASON); } #endregion page.Result = list; result.Result = dataPage; } catch (Exception ex) { throw ex; } result.IsSuccess = true; return result; } /// /// Form获取列表 /// /// 条件 /// 数据页 /// 数据页 public DataPage GetList(ProductOut condition, DataPage page) { try { page = new ProductOutDAL().GetList(condition, page); List list = page.Result as List; page.Result = list; return page; } catch (Exception ex) { throw ex; } } #endregion #region 导出数据 /// /// 获取导出的数据 /// /// 查询条件 /// 数据 public DataTable GetExportData(ProductOut model) { try { DataTable dt = new ProductOutDAL().GetExportData(model); //处理字典信息 DictManageBLL dictOUTREASON = new DictManageBLL(DictKind.OUTREASON); foreach (DataRow dr in dt.Rows) { //替换状态类别显示值 dr["OUTREASON"] = dictOUTREASON.GetDictValue(dr["OUTREASON"].ToString()); } //根据所选信息进行导出 if (string.IsNullOrEmpty(model.PIDList) == false) { model.PIDList = "'" + model.PIDList.Replace(":", "','") + "'"; DataView dv = new DataView(dt); dv.RowFilter = "PID in (" + model.PIDList + ")"; dt = dv.ToTable(); } return dt; } catch (Exception ex) { throw ex; } } #endregion #region 更新产品表信息(出库状态) /// /// 更新产品表信息(出库状态) /// /// /// public DataResult InsertProductOut(ProductOut model) { DataResult result = new DataResult(); Product productinfo = new Product(); try { //基本信息 model.UPDATEUSER = model.CREATEUSER; model.UPDATEDATE = model.CREATEDATE; foreach (var item in model.productList) { item.OUTFLAG = EnumGeter.OUTFLAG.OUTWAREHOUSE.GetHashCode().ToString(); } result.Result = new ProductOutDAL().InsertProductOut(model); result.IsSuccess = true; result.Msg = "操作成功!"; } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "产品表更新插入异常!" }); result.IsSuccess = false; result.Ex = ex; } return result; } #endregion #region 获取出库原因列表(winform使用) /// /// 获取出库原因列表(winform使用) /// /// /// public List GetOutReasonList(OutReason condition) { List result = new List(); try { List list = new ProductOutDAL().GetOutReasonList(condition); return list; } catch (Exception ex) { throw ex; } } #endregion #region 获取每种零件号的出库数量 /// /// 获取出库数量 /// /// /// public int GetProductOutConut(string materialCode) { int materialCount = 0; string sql = string.Format("select count(1) from T_AW_PRODUCTOUT where MATERIAL_CODE='{0}'", materialCode); using (IDataSession session = AppDataFactory.CreateMainSession()) { materialCount = Convert.ToInt32(session.ExecuteSqlScalar(sql, new List().ToArray())); } return materialCount; } #endregion } }