예제 #1
0
        public ActionResult ProductInfo_FindByPage(Mes_Tec_ProductInfo obj, int page, int rows)
        {
            var pager = new PagerBase()
            {
                CurrentPageIndex = page, PageSize = rows
            };
            var list = MesTecProductInfoDao.Instance.FindByPage(obj, ref pager);

            return(Json(new { total = pager.TotalItemCount, rows = list }));
        }
예제 #2
0
        private ImportMessageModel ProductInfo_FormatRow(DataRow row, Mes_Tec_ProductInfo itemObj, int rowIndex)
        {
            ImportMessageModel errorObj = null;

            try
            {
                //导入样品
                string sTemp = "";
                itemObj.MaterialProNo = TConvertHelper.FormatDBString(row["物料编码"]);
                itemObj.MaterialCode  = TConvertHelper.FormatDBString(row["物料名称"]);
                sTemp = TConvertHelper.FormatDBString(row["物料分类"]);
                if (!string.IsNullOrEmpty(sTemp))
                {
                    itemObj.MaterialClass = StatusHelper.GetStatusByDescription <MaterialClassStatus>(sTemp);
                }
                sTemp = TConvertHelper.FormatDBString(row["批次属性"]);
                if (!string.IsNullOrEmpty(sTemp))
                {
                    itemObj.TraceProperty = TConvertHelper.FormatDBInt(StatusHelper.GetStatusByDescription <MaterialClassStatus>(sTemp));
                }
                itemObj.MaterialSize = TConvertHelper.FormatDBString(row["规格尺寸"]);
                itemObj.Unit         = TConvertHelper.FormatDBString(row["单位"]);
                itemObj.PackNumber   = TConvertHelper.FormatDBInt(row["每箱数量"]);
                itemObj.Memo         = TConvertHelper.FormatDBString(row["备注"]);
                //itemObj.CreatedTime = DateTime.Now;
                if (string.IsNullOrEmpty(itemObj.MaterialProNo) || string.IsNullOrEmpty(itemObj.MaterialCode))
                {
                    return(new ImportMessageModel()
                    {
                        RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = "物料编码、物料名称不能为空"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ImportMessageModel()
                {
                    RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = ex.Message
                });
            }

            return(errorObj);
        }
예제 #3
0
        /// <summary>
        /// 获取单个用户实体
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public Mes_Tec_ProductInfo GetProductInfo(Mes_Tec_ProductInfo obj)
        {
            List <SqlParameter> list = new List <SqlParameter>();
            string sql = "select top 1 * from Mes_Tec_ProductInfo where 1=1 ";

            if (!string.IsNullOrEmpty(obj.MaterialProNo))
            {
                sql = sql + string.Format(" AND MaterialProNo='{0}'", obj.MaterialProNo);
            }
            if (!string.IsNullOrEmpty(obj.MaterialCode))
            {
                sql = sql + string.Format(" AND MaterialCode='{0}'", obj.MaterialCode);
            }
            if (!string.IsNullOrEmpty(obj.MaterialClass))
            {
                sql = sql + string.Format(" AND MaterialClass='{0}'", obj.MaterialClass);
            }
            return(this.CurDbSession.FromSql(sql.ToString()).ToFirstDefault <Mes_Tec_ProductInfo>());
        }
예제 #4
0
        /// <summary>
        /// 保存用户
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool Save(Mes_Tec_ProductInfo obj)
        {
            int result = -1;

            if (obj.ID > 0)
            {
                //修改
                result = this.CurDbSession.Update <Mes_Tec_ProductInfo>(obj);
            }
            else
            {
                result = this.CurDbSession.Insert <Mes_Tec_ProductInfo>(obj);
            }
            if (result < 0)
            {
                return(false);
            }
            return(true);
        }
예제 #5
0
        public ActionResult ProductInfo_Select(int page, int rows, string q)
        {
            List <Mes_Tec_ProductInfo> list = null;
            Mes_Tec_ProductInfo        obj  = new Mes_Tec_ProductInfo();

            if (!string.IsNullOrEmpty(q))
            {
                obj.MaterialProNo = q;
            }
            var pager = new PagerBase()
            {
                CurrentPageIndex = page, PageSize = rows
            };

            list = MesTecProductInfoDao.Instance.FindByPage(obj, ref pager);
            if (list == null)
            {
                list = new List <Mes_Tec_ProductInfo>();
            }

            return(Json(new { total = pager.TotalItemCount, rows = list, JsonRequestBehavior.AllowGet }));
        }
예제 #6
0
        /// <summary>
        /// 保存记录
        /// </summary>
        /// <returns></returns>
        public ActionResult ProductInfo_Save(Mes_Tec_ProductInfo obj)
        {
            string sMessage = string.Empty;

            //判断数据有效性
            if (string.IsNullOrEmpty(obj.MaterialProNo))
            {
                sMessage = "物料编号不可为空";
                return(Json(new { IsSuccess = false, Message = sMessage }, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(obj.MaterialCode))
            {
                sMessage = "物料名称不可为空";
                return(Json(new { IsSuccess = false, Message = sMessage }, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(obj.MaterialClass))
            {
                sMessage = "物料分类不可为空";
                return(Json(new { IsSuccess = false, Message = sMessage }, JsonRequestBehavior.AllowGet));
            }
            if (obj.ID > 0)
            {
                obj.Modifier     = base.CurUser.UserId;
                obj.ModifiedTime = DateTime.Now;
            }
            else
            {
                obj.Creater     = base.CurUser.UserId;
                obj.CreatedTime = DateTime.Now;
            }
            bool result = MesTecProductInfoDao.Instance.Save(obj);

            if (!result)
            {
                sMessage = "保存失败";
                return(Json(new { IsSuccess = false, Message = sMessage }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { IsSuccess = true, Message = sMessage }, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="pager"></param>
        /// <returns></returns>
        public List <Mes_Tec_ProductInfo> FindByPage(Mes_Tec_ProductInfo obj, ref PagerBase pager)
        {
            string sql = @"select T1.*,T2.StockName as Show_StockCode,T3.AlibraryName as Show_AlibraryCode from Mes_Tec_ProductInfo T1 
                        Left join Mes_Sys_Stock T2 ON T1.StockCode=T2.StockCode 
                        left join Mes_Sys_Alibrary T3 ON T1.AlibrayCode=T3.AlibraryCode 
                        WHERE   1=1 ";

            if (!string.IsNullOrEmpty(obj.MaterialProNo))
            {
                sql += string.Format(" AND T1.MaterialProNo Like '%{0}%'", obj.MaterialProNo);
            }

            if (!string.IsNullOrEmpty(obj.MaterialCode))
            {
                sql += string.Format(" AND T1.MaterialCode Like '%{0}%'", obj.MaterialCode);
            }
            if (!string.IsNullOrEmpty(obj.MaterialClass) && obj.MaterialClass != "-1")
            {
                sql += string.Format(" AND T1.MaterialClass Like '%{0}%'", obj.MaterialClass);
            }
            if (obj.MaterialStatus > 0)
            {
                sql += string.Format(" AND T1.MaterialStatus={0}", obj.MaterialStatus);
            }

            string orderBy = pager.OrderBy;

            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "CreatedTime DESC";
            }
            string cmdPageSql  = string.Format(BaseDao.PageSql, orderBy, sql, pager.StartNo, pager.EndNo);
            string cmdCountSql = string.Format(BaseDao.CountSql, sql.Substring(sql.ToLower().IndexOf("from", StringComparison.Ordinal)));

            //查询总记录数
            pager.TotalItemCount = this.CurDbSession.FromSql(cmdCountSql).ToScalar <int>();
            //返回当前页的记录数
            return(this.CurDbSession.FromSql(cmdPageSql).ToList <Mes_Tec_ProductInfo>());
        }
예제 #8
0
        private IList <ImportMessageModel> Import_ProductInfo(DataTable dtData)
        {
            IList <ImportMessageModel> resultList = new List <ImportMessageModel>();
            //提示用户导入消息有错,但不影响数据导入
            IList <ImportMessageModel> msgList        = new List <ImportMessageModel>();
            List <Mes_Tec_ProductInfo> productAllList = null;
            List <Mes_Tec_ProductInfo> dataList       = new List <Mes_Tec_ProductInfo>();
            int                rowIndex = 0; //第1行是行头
            DateTime           time     = DateTime.Now;
            ImportMessageModel errorObj = null;

            if (dtData != null && dtData.Rows.Count > 0)
            {
                productAllList = MesTecProductInfoDao.Instance.FindAll <Mes_Tec_ProductInfo>();
                Mes_Tec_ProductInfo productObj = null;
                foreach (DataRow row in dtData.Rows)
                {
                    rowIndex++;
                    productObj             = new Mes_Tec_ProductInfo();
                    productObj.CreatedTime = time;
                    productObj.Creater     = curUserId;
                    //存样品信息
                    errorObj = ProductInfo_FormatRow(row, productObj, rowIndex);
                    if (errorObj != null) //记录行错误信息
                    {
                        resultList.Add(errorObj);
                        continue;
                    }

                    //检测物料编码是否重复,不允许重复
                    if (productAllList.Exists(p => p.MaterialProNo == productObj.MaterialProNo))
                    {
                        resultList.Add(new ImportMessageModel()
                        {
                            RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("物料编码【{0}】已经存在", productObj.MaterialProNo)
                        });
                    }
                    if (dataList.Exists(p => p.MaterialProNo == productObj.MaterialProNo))
                    {
                        resultList.Add(new ImportMessageModel()
                        {
                            RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("物料编码【{0}】重复导入", productObj.MaterialProNo)
                        });
                    }

                    dataList.Add(productObj);
                }
            }


            //如果校验有错误,直接返回错误信息
            if (resultList.Count > 0)
            {
                return(resultList);
            }
            //2.校验成功执行导入
            MesTecProductInfoDao.Instance.Import(dataList, resultList);
            if (resultList.Count == 0)
            {
                resultList.Add(new ImportMessageModel {
                    RowData = "导入成功", RowMessage = "数据已成功导入"
                });
            }

            return(resultList);
        }
예제 #9
0
        private IList <ImportMessageModel> Import_TecProcessBom(DataTable dtData)
        {
            IList <ImportMessageModel> resultList = new List <ImportMessageModel>();
            //提示用户导入消息有错,但不影响数据导入
            IList <ImportMessageModel>    msgList     = new List <ImportMessageModel>();
            List <Mes_Tec_ProcessBom>     bomList     = new List <Mes_Tec_ProcessBom>();
            List <Mes_Tec_ProcessBomItem> dataList    = new List <Mes_Tec_ProcessBomItem>();
            List <Mes_Tec_Process>        processList = null;
            List <Mes_Tec_ProductInfo>    productList = null;
            int                rowIndex = 0; //第1行是行头
            DateTime           time     = DateTime.Now;
            ImportMessageModel errorObj = null;

            if (dtData != null && dtData.Rows.Count > 0)
            {
                Mes_Tec_ProcessBom     bomObj     = null;
                Mes_Tec_ProcessBomItem bomItemObj = null;
                Mes_Tec_Process        processObj = null;
                Mes_Tec_ProductInfo    productObj = null;

                processList = MesTecProcessDao.Instance.FindAll <Mes_Tec_Process>();
                productList = MesTecProductInfoDao.Instance.FindAll <Mes_Tec_ProductInfo>();
                foreach (DataRow row in dtData.Rows)
                {
                    rowIndex++;
                    bomItemObj             = new Mes_Tec_ProcessBomItem();
                    bomItemObj.CreatedTime = time;
                    bomItemObj.Creater     = curUserId;
                    //存样品信息
                    errorObj = TecProcessBom_FormatRow(row, bomItemObj, rowIndex);
                    if (errorObj != null) //记录行错误信息
                    {
                        resultList.Add(errorObj);
                        continue;
                    }

                    processObj = processList.Where(p => p.Name == bomItemObj.ProcessName && p.RecordStatus == 1).FirstOrDefault();
                    if (processObj == null)
                    {
                        msgList.Add(new ImportMessageModel()
                        {
                            RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("工艺【{0}】不存在", bomItemObj.ProcessName)
                        });
                    }
                    else
                    {
                        bomItemObj.ProcessID = processObj.ID;
                    }

                    productObj = productList.Where(p => p.MaterialProNo == bomItemObj.MaterialProNo).FirstOrDefault();
                    if (productObj == null)
                    {
                        msgList.Add(new ImportMessageModel()
                        {
                            RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("产品编码【{0}】不存在", bomItemObj.MaterialProNo)
                        });
                    }
                    else
                    {
                        bomItemObj.MaterialCode = productObj.MaterialCode;
                        if (!bomList.Exists(p => p.MaterialProNo == bomItemObj.MaterialProNo && p.Version == bomItemObj.Version))
                        {
                            bomObj = new Mes_Tec_ProcessBom();
                            bomObj.MaterialProNo = bomItemObj.MaterialProNo;
                            bomObj.MaterialCode  = bomItemObj.MaterialCode;
                            bomObj.Version       = bomItemObj.Version;
                            bomObj.CreatedTime   = time;
                            bomObj.Creater       = curUserId;
                            bomList.Add(bomObj);
                        }
                    }

                    productObj = productList.Where(p => p.MaterialProNo == bomItemObj.SubMaterialProNo).First();
                    if (productObj == null)
                    {
                        msgList.Add(new ImportMessageModel()
                        {
                            RowData = string.Format(ReadErrorMessage, rowIndex), RowMessage = string.Format("物料编码【{0}】不存在", bomItemObj.MaterialProNo)
                        });
                    }
                    else
                    {
                        bomItemObj.SubMaterialCode = productObj.MaterialCode;
                    }

                    dataList.Add(bomItemObj);
                }
            }


            //如果校验有错误,直接返回错误信息
            if (resultList.Count > 0)
            {
                return(resultList);
            }
            //2.校验成功执行导入
            MesTecProcessBomDao.Instance.Import(bomList, dataList, resultList);
            if (resultList.Count == 0)
            {
                resultList.Add(new ImportMessageModel {
                    RowData = "导入成功", RowMessage = "数据已成功导入"
                });
            }

            return(resultList);
        }