コード例 #1
0
ファイル: ProcessBomMgt.cs プロジェクト: johden2/Demo0603
        public ActionResult ProcessBomMgt_Delete(Mes_Tec_ProcessBom obj)
        {
            if (string.IsNullOrEmpty(obj.MaterialProNo))
            {
                return(Json(new { IsSuccess = false, Message = "【产品编码】有误!" }));
            }
            if (string.IsNullOrEmpty(obj.Version))
            {
                return(Json(new { IsSuccess = false, Message = "【产品版本】有误!" }));
            }

            Mes_Tec_ProcessBom searchObj = new Mes_Tec_ProcessBom();

            searchObj.MaterialProNo = obj.MaterialProNo;
            searchObj.Version       = obj.Version;
            Mes_Tec_ProcessBom resultObj = MesTecProcessBomDao.Instance.FindExt(searchObj);

            if (resultObj == null || resultObj.ID <= 0)
            {
                return(Json(new { IsSuccess = false, Message = "产品信息有误,请刷新后重试!" }));
            }

            MesTecProcessBomDao.Instance.DeleteExt(resultObj);
            return(Json(new { IsSuccess = true, Message = "操作成功!" }));
        }
コード例 #2
0
        /// <summary>
        /// 获取树结构
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public string GetTree(Mes_Tec_ProcessBom obj)
        {
            string sql = @"SELECT ID,MaterialProNo,Version,MaterialCode FROM dbo.Mes_Tec_ProcessBom T1 WITH(NOLOCK) WHERE 1=1";
            List <Mes_Tec_ProcessBom> list    = this.CurDbSession.FromSql(sql).ToList <Mes_Tec_ProcessBom>();
            StringBuilder             jsonStr = new StringBuilder();

            if (list != null && list.Count > 0)
            {
                jsonStr.Append("[");
                int             index   = 0;
                List <KeyModel> keyList = list.Select(p => new KeyModel {
                    Key = p.MaterialProNo, Value = p.MaterialCode
                })
                                          .GroupBy(p => new { p.Key, p.Value })
                                          .Select(g => g.First())
                                          .ToList();

                foreach (var item in keyList)
                {
                    index++;
                    jsonStr.Append("{");
                    jsonStr.Append(_itemHTML.Replace("[0]", index.ToString()).Replace("[1]", item.Value).Replace("[2]", item.Key).Replace("[3]", "").Replace("[4]", item.Value));
                    GetChildNodes(list, item, jsonStr, ref index);
                    jsonStr.Append("},");
                }
                jsonStr = jsonStr.Remove(jsonStr.Length - 1, 1);
                jsonStr.Append("]");
            }

            return(jsonStr.ToString());
        }
コード例 #3
0
        /// <summary>
        /// 保存明细
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="resultObj"></param>
        /// <returns></returns>
        public bool SaveBomItem(Mes_Tec_ProcessBom obj, Mes_Tec_ProcessBom resultObj)
        {
            int result = -1;

            //2.保存明细
            Mes_Tec_ProcessBomItem itemObj = new Mes_Tec_ProcessBomItem();

            itemObj.ID               = obj.ItemID;
            itemObj.ProcessBomID     = resultObj.ID;
            itemObj.ProcessID        = obj.ProcessID;
            itemObj.SubMaterialProNo = obj.SubMaterialProNo;
            itemObj.SubMaterialCode  = obj.SubMaterialCode;
            itemObj.Num              = obj.Num;
            itemObj.Unit             = obj.Unit;
            itemObj.Memo             = obj.Memo;

            if (itemObj.ID > 0)
            {
                result = this.CurDbSession.Update <Mes_Tec_ProcessBomItem>(itemObj);
            }
            else
            {
                itemObj.Creater     = obj.Creater;
                itemObj.CreatedTime = obj.CreatedTime;
                result = this.CurDbSession.Insert <Mes_Tec_ProcessBomItem>(itemObj);
            }

            return(true);
        }
コード例 #4
0
ファイル: ProcessBomMgt.cs プロジェクト: johden2/Demo0603
        public ActionResult ProcessBomMgt_FindByPage(Mes_Tec_ProcessBom obj, int page, int rows)
        {
            var pager = new PagerBase()
            {
                CurrentPageIndex = page, PageSize = rows
            };
            var list = MesTecProcessBomDao.Instance.FindByPage(obj, ref pager);

            return(Json(new { total = pager.TotalItemCount, rows = list }, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public bool DeleteExt(Mes_Tec_ProcessBom obj)
        {
            string sql = "DELETE FROM Mes_Tec_ProcessBomItem WHERE ProcessBomID = {0}";

            sql = string.Format(sql, obj.ID);
            int result = this.CurDbSession.FromSql(sql).ExecuteNonQuery();

            this.CurDbSession.Delete(obj);
            return(true);
        }
コード例 #6
0
        /// <summary>
        /// 获取实体对象
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public Mes_Tec_ProcessBom FindExt(Mes_Tec_ProcessBom obj)
        {
            string sql = "SELECT T1.* FROM dbo.Mes_Tec_ProcessBom T1 WITH(NOLOCK) WHERE 1=1";

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

            return(this.CurDbSession.FromSql(sql).ToFirst <Mes_Tec_ProcessBom>());
        }
コード例 #7
0
ファイル: ProcessBomMgt.cs プロジェクト: johden2/Demo0603
        public ActionResult ProcessBomMgt_SaveBomItem(Mes_Tec_ProcessBom obj)
        {
            if (string.IsNullOrEmpty(obj.MaterialProNo))
            {
                return(Json(new { IsSuccess = false, Message = "【产品编码】不能为空!" }));
            }
            if (string.IsNullOrEmpty(obj.MaterialCode))
            {
                return(Json(new { IsSuccess = false, Message = "【产品简称】不能为空!" }));
            }
            if (string.IsNullOrEmpty(obj.Version))
            {
                return(Json(new { IsSuccess = false, Message = "【产品版本】不能为空!" }));
            }
            if (string.IsNullOrEmpty(obj.SubMaterialProNo))
            {
                return(Json(new { IsSuccess = false, Message = "【物料编码】不能为空!" }));
            }
            if (string.IsNullOrEmpty(obj.SubMaterialCode))
            {
                return(Json(new { IsSuccess = false, Message = "【物料简称】不能为空!" }));
            }
            if (obj.Num <= 0)
            {
                return(Json(new { IsSuccess = false, Message = "【数量】不能为空!" }));
            }
            if (string.IsNullOrEmpty(obj.Unit))
            {
                return(Json(new { IsSuccess = false, Message = "【单位】不能为空!" }));
            }

            Mes_Tec_ProcessBom searchObj = new Mes_Tec_ProcessBom();

            searchObj.MaterialProNo = obj.MaterialProNo;
            searchObj.Version       = obj.Version;
            Mes_Tec_ProcessBom resultObj = MesTecProcessBomDao.Instance.FindExt(searchObj);

            if (resultObj == null)
            {
                return(Json(new { IsSuccess = false, Message = "产品信息有误,请刷新后重试!" }));
            }

            obj.Creater     = base.CurUser.UserId;
            obj.CreatedTime = DateTime.Now;

            MesTecProcessBomDao.Instance.SaveBomItem(obj, resultObj);
            return(Json(new { IsSuccess = true, Message = "操作成功!" }));
        }
コード例 #8
0
        public List <Mes_Tec_ProcessBom> FindByPage(Mes_Tec_ProcessBom obj, ref PagerBase pager)
        {
            string sql = @"SELECT T1.ID,T1.MaterialProNo,T1.Version,T1.MaterialCode,T2.ID AS ItemID,T2.SubMaterialProNo,T2.SubMaterialCode,T2.Num,T2.Unit,T2.Memo,T2.ProcessID,T3.Name AS ProcessName 
                        FROM dbo.Mes_Tec_ProcessBom T1 WITH(NOLOCK) 
                        INNER JOIN Mes_Tec_ProcessBomItem T2 WITH(NOLOCK) ON T1.ID = T2.ProcessBomID
                        LEFT JOIN dbo.Mes_Tec_Process T3 WITH(NOLOCK) ON T2.ProcessID = T3.ID
                        WHERE 1=1";

            if (!string.IsNullOrEmpty(obj.MaterialProNo))
            {
                sql += string.Format(" AND T1.MaterialProNo = '{0}'", obj.MaterialProNo);
            }
            if (!string.IsNullOrEmpty(obj.SubMaterialProNo))
            {
                sql += string.Format(" AND T2.SubMaterialProNo Like '%{0}%'", obj.SubMaterialProNo);
            }
            if (!string.IsNullOrEmpty(obj.MaterialCode))
            {
                sql += string.Format(" AND T1.MaterialCode = '{0}'", obj.MaterialCode);
            }
            if (!string.IsNullOrEmpty(obj.SubMaterialCode))
            {
                sql += string.Format(" AND T2.SubMaterialCode Like '%{0}%'", obj.SubMaterialCode);
            }
            if (!string.IsNullOrEmpty(obj.Version))
            {
                sql += string.Format(" AND T1.Version = '{0}'", obj.Version);
            }
            if (obj.ProcessID > 0)
            {
                sql += string.Format(" AND T2.ProcessID = '{0}'", obj.ProcessID);
            }

            string orderBy = pager.OrderBy;

            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "MaterialProNo ASC,Version DESC,SubMaterialProNo ASC";
            }
            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_ProcessBom>());
        }
コード例 #9
0
ファイル: ProcessBomMgt.cs プロジェクト: johden2/Demo0603
        public ActionResult ProcessBomMgt_DeleteBomItem(Mes_Tec_ProcessBom obj)
        {
            if (obj.ItemID <= 0)
            {
                return(Json(new { IsSuccess = false, Message = "传入的参数有误!" }));
            }

            Mes_Tec_ProcessBomItem itemObj = MesTecProcessBomDao.Instance.Find <Mes_Tec_ProcessBomItem, int>(obj.ItemID);

            if (itemObj == null)
            {
                return(Json(new { IsSuccess = false, Message = "物料信息有误,请刷新后重试!" }));
            }

            MesTecProcessBomDao.Instance.Delete <Mes_Tec_ProcessBomItem>(itemObj);
            return(Json(new { IsSuccess = true, Message = "操作成功!" }));
        }
コード例 #10
0
ファイル: ProcessBomMgt.cs プロジェクト: johden2/Demo0603
        public ActionResult ProcessBomMgt_Find(Mes_Tec_ProcessBom obj)
        {
            if (string.IsNullOrEmpty(obj.MaterialProNo))
            {
                return(Json(new { IsSuccess = false, Message = "【产品编码】有误!" }));
            }
            if (string.IsNullOrEmpty(obj.Version))
            {
                return(Json(new { IsSuccess = false, Message = "【产品版本】有误!" }));
            }
            Mes_Tec_ProcessBom result = MesTecProcessBomDao.Instance.FindExt(obj);

            if (result == null)
            {
                return(Json(new { IsSuccess = false, Message = "信息不存在,请刷新后重试!" }));
            }

            return(Json(new { IsSuccess = true, Message = JsonHelper.SerializeObject(result) }, JsonRequestBehavior.AllowGet));
        }
コード例 #11
0
ファイル: ProcessBomMgt.cs プロジェクト: johden2/Demo0603
        public ActionResult ProcessBomMgt_SaveBom(Mes_Tec_ProcessBom obj)
        {
            if (string.IsNullOrEmpty(obj.MaterialProNo))
            {
                return(Json(new { IsSuccess = false, Message = "【产品编码】不能为空!" }));
            }
            if (string.IsNullOrEmpty(obj.MaterialCode))
            {
                return(Json(new { IsSuccess = false, Message = "【产品简称】不能为空!" }));
            }
            if (string.IsNullOrEmpty(obj.Version))
            {
                return(Json(new { IsSuccess = false, Message = "【产品版本】不能为空!" }));
            }

            Mes_Tec_ProcessBom searchObj = new Mes_Tec_ProcessBom();

            searchObj.MaterialProNo = obj.MaterialProNo;
            searchObj.Version       = obj.Version;
            Mes_Tec_ProcessBom resultObj = MesTecProcessBomDao.Instance.FindExt(searchObj);

            if (resultObj == null)
            {
                resultObj             = obj;
                resultObj.ID          = 0;
                resultObj.Creater     = base.CurUser.UserId;
                resultObj.CreatedTime = DateTime.Now;
            }
            else
            {
                resultObj.Memo         = obj.Memo;
                resultObj.MaterialCode = obj.MaterialCode;
            }

            MesTecProcessBomDao.Instance.Save(resultObj);
            return(Json(new { IsSuccess = true, Message = "操作成功!" }));
        }
コード例 #12
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);
        }
コード例 #13
0
ファイル: ProcessBomMgt.cs プロジェクト: johden2/Demo0603
        /// <summary>
        /// 获取主表产品树
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public string ProcessBomMgt_FindTree(Mes_Tec_ProcessBom obj)
        {
            string result = MesTecProcessBomDao.Instance.GetTree(obj);

            return(result);
        }