Ejemplo n.º 1
0
        public Paging <List <partBriefModel> > GetPartList(int start, int limit)
        {
            PartBLL partBll = new PartBLL();
            Paging <List <partBriefModel> > list = partBll.GetPartList(null, start, limit);

            return(list);
        }
Ejemplo n.º 2
0
        public PartModel GetPartDetail(int id)
        {
            PartBLL   partBll = new PartBLL();
            PartModel detail  = partBll.GetPartDetail(id);

            return(detail);
        }
Ejemplo n.º 3
0
        public Paging <List <partBriefModel> > GetPartList(string filter, int start, int limit)
        {
            List <Filter> filters = JsonConvert.DeserializeObject <List <Filter> >(filter);
            PartBLL       partBll = new PartBLL();
            Paging <List <partBriefModel> > list = partBll.GetPartList(filters, start, limit);

            return(list);
        }
Ejemplo n.º 4
0
        public void DeletePartTest1()
        {
            PartBLL target = new PartBLL(); // TODO: Initialize to an appropriate value
            Part    part   = null;          // TODO: Initialize to an appropriate value

            target.DeletePart(part);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Ejemplo n.º 5
0
        public void GetPartsTest1()
        {
            PartBLL     target   = new PartBLL(); // TODO: Initialize to an appropriate value
            List <Part> expected = null;          // TODO: Initialize to an appropriate value
            List <Part> actual;

            actual = target.GetParts();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 6
0
        public void GetPartbyKeyTest()
        {
            PartBLL target = new PartBLL(); // TODO: Initialize to an appropriate value
            Part    part   = new Part {
                PartID = new Guid("8625D5D6-D1FB-4494-9D90-82284DC5AE55")
            };
            Part expected = null; // TODO: Initialize to an appropriate value
            Part actual;

            actual = target.GetPartbyKey(part);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 7
0
        // User view for all parts
        public ActionResult ViewAllParts(DirtbikeModel iDirtbikeModel, PartModel iPartModel)
        {
            // Must be logged in to any role to access this view
            if (((LoginModel)Session["loginModel"]) != null)
            {
                MapperDirtbike map       = new MapperDirtbike();
                Dirtbike       iDirtbike = new Dirtbike();
                iDirtbike = map.MapDirtbike(iDirtbikeModel);
                DirtbikeBLL selectDirtbike = new DirtbikeBLL();

                // Returned list of Dirtbikes from Database
                List <Dirtbike> listDirtbike = selectDirtbike.Select(iDirtbike);

                /* Get Dirtbike values from database and set it to
                 * viewbag to pass it to view for drop downlist*/
                IEnumerable <SelectListItem> makes = listDirtbike.Select(m => new SelectListItem
                {
                    Value = m.Make,
                    Text  = m.Make
                });
                ViewBag.Make = makes;
                IEnumerable <SelectListItem> makeYear = listDirtbike.Select(m => new SelectListItem
                {
                    Value = m.MakeYear.ToString(),
                    Text  = m.MakeYear.ToString()
                });
                ViewBag.MakeYear = makeYear;
                IEnumerable <SelectListItem> models = listDirtbike.Select(m => new SelectListItem
                {
                    Value = m.Model,
                    Text  = m.Model
                });
                ViewBag.Model = models;


                /* PartModel */
                PartMapper partMap = new PartMapper();
                Part       iPart   = new Part();
                iPart = partMap.MapDirtbike(iPartModel);
                PartBLL selectPart = new PartBLL();

                // Create List object for returned parts
                List <Part> listParts = selectPart.SelectAllParts(iPart);

                return(View(listParts));
            }
            else
            {
                return(RedirectToAction("login", "home"));
            }
        }
Ejemplo n.º 8
0
        public void AddPartTest()
        {
            PartBLL target = new PartBLL(); // TODO: Initialize to an appropriate value
            Part    part   = CreatePart();

            //Part expected = null; // TODO: Initialize to an appropriate value

            Part actual;

            using (target.Context)
            {
                actual = target.AddPart(part);
            }
            Assert.IsNotNull(actual.PartID);//.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 9
0
        public ActionResult ViewPartsTable()
        {
            // Must be admin or moderator to access
            if (((LoginModel)Session["loginModel"]) != null && ((LoginModel)Session["loginModel"]).RoleIDFK != 3)
            {
                Part    iPart      = new Part();
                PartBLL selectPart = new PartBLL();

                // Create List object for returned parts
                List <Part> listParts = selectPart.SelectAllParts(iPart);

                return(View(listParts));
            }
            else
            {
                return(RedirectToAction("login", "home"));
            }
        }
Ejemplo n.º 10
0
        public void UpdatePartTest()
        {
            // TODO: Initialize to an appropriate value
            Part part = CreatePart();// new Part { PartID = new System.Guid("365A5D23-292C-42FF-BCC6-6BAF2F8EBA80") };

            part.PartID = new System.Guid("51B384C7-EEAF-4B06-8607-B817A32C6284");
            //part.PartSegments.Clear();
            part.PartSegments.Add(new PartSegment {
                Part = part, Segment = new Segment {
                    SegmentID = 5
                }
            });
            //Part part = target.GetPartbyKey(p);// TODO: Initialize to an appropriate value
            part.PartChineseName = "测试零件 01";
            part.Plant.PlantID   = 5;
            PartBLL target = new PartBLL();

            //part.EntityKey = target.Context.CreateEntityKey("Part", part);
            target.UpdatePart(part);

            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 11
0
        // User View for specific part
        public ActionResult ViewPart(PartModel iPartID)
        {
            // Must be logged in to any role to access this view
            if (((LoginModel)Session["loginModel"]) != null)
            {
                ViewBag.Title = "Part View";


                /* PartModel */
                PartMapper partMap = new PartMapper();
                Part       iPart   = new Part();
                iPart = partMap.MapDirtbike(iPartID);
                PartBLL selectPart = new PartBLL();

                // Create List object for returned parts where partID is the same as partID from user clicked part in Parts view
                List <Part> part = selectPart.SelectAllParts(iPart).Where(p => p.PartID == iPartID.PartID).ToList();

                return(View(part));
            }
            else
            {
                return(RedirectToAction("login", "home"));
            }
        }
Ejemplo n.º 12
0
        public bool UpdateData(string F_Id, DataTable totalTable)
        {
            DataTable bomTable = new DataTable();

            bomTable.Columns.Add("零件编码", typeof(System.String));
            bomTable.Columns.Add("零件数量", typeof(System.Int32));

            List <T_Product> productList = new ProductBLL().GetList();
            List <T_Part>    partList    = new PartBLL().GetList();
            T_Product        t_product   = new T_Product();

            //判断产品,添加产品
            if (productList.Where(x => x.F_Name == totalTable.Rows[1]["Column2"].ToString()).ToList().Count == 0)
            {
                if (productList.Where(x => x.F_Code == totalTable.Rows[2]["Column2"].ToString()).ToList().Count == 0)
                {
                    //添加产品
                    try
                    {
                        if (!string.IsNullOrEmpty(totalTable.Rows[1]["Column2"].ToString()))
                        {
                            t_product.F_Name = totalTable.Rows[1]["Column2"].ToString();
                        }
                        else
                        {
                            throw new Exception("产品名称不能为空,请检查");
                        }
                    }
                    catch (Exception)
                    {
                        throw new Exception("产品名称异常,请检查");
                    }
                    try
                    {
                        if (!string.IsNullOrEmpty(totalTable.Rows[2]["Column2"].ToString()))
                        {
                            t_product.F_Code = totalTable.Rows[2]["Column2"].ToString();
                        }
                        else
                        {
                            throw new Exception("产品编码不能为空,请检查");
                        }
                    }
                    catch (Exception)
                    {
                        throw new Exception("产品编码异常,请检查");
                    }
                    t_product.F_Create_By   = ManageProvider.Provider.Current().User.F_Account;
                    t_product.F_Create_Time = DateTime.Now;
                }
                else
                {
                    throw new Exception("产品编码重复,请检查");
                }
            }


            //添加零件,分解出bom详情table
            for (int i = 5; i < totalTable.Rows.Count; i++)
            {
                DataRow dr = bomTable.NewRow();
                try
                {
                    if (!string.IsNullOrEmpty(totalTable.Rows[i]["Column2"].ToString()))
                    {
                        if (partList.Select(x => x.F_Code.PadRight(12, '0') == totalTable.Rows[i]["Column2"].ToString().PadRight(12, '0')).ToList().Count > 0)
                        {
                            dr["零件编码"] = totalTable.Rows[i]["Column2"].ToString().PadRight(12, '0');
                        }
                        else
                        {
                            throw new Exception("数据源第" + Convert.ToInt32(i + 2) + "行零件编码不存在,请检查");
                        }
                    }
                    else
                    {
                        throw new Exception("数据源第" + Convert.ToInt32(i + 2) + "行零件编码为空,请检查");
                    }
                }
                catch (Exception)
                {
                    throw new Exception("数据源第" + Convert.ToInt32(i + 2) + "行零件编码异常,请检查");
                }
                try
                {
                    if (!string.IsNullOrEmpty(totalTable.Rows[i]["Column5"].ToString()))
                    {
                        dr["零件数量"] = int.Parse(totalTable.Rows[i]["Column5"].ToString());
                    }
                    else
                    {
                        throw new Exception("数据源第" + Convert.ToInt32(i + 2) + "行零件数量为空,请检查");
                    }
                }
                catch (Exception)
                {
                    throw new Exception("数据源第" + Convert.ToInt32(i + 2) + "行零件数量异常,请检查");
                }
                bomTable.Rows.Add(dr);//添加零件临时表
            }
            List <T_Bom_Detail> insertBomDetailList = new List <T_Bom_Detail>();
            var query = from t in bomTable.AsEnumerable()
                        group t by new { t1 = t.Field <string>("零件编码") } into m
                select new
            {
                pob      = m.Key.t1,
                rowcount = m.Count()
            };
            int j = 0;

            foreach (var q in query)
            {
                j++;
                if (q.rowcount > 1)
                {
                    throw new Exception("数据源第" + Convert.ToInt32(j + 6) + "行零件编码有重复,请检查");
                }
            }//验证导入Excel是否存在重复编码

            //int InsertId = new Repository<T_Bom_Detail>().FindCountBySql("SELECT ISNULL(MAX(F_ID), 0) + 1 FROM T_BOM_DETAIL");
            for (int i = 0; i < bomTable.Rows.Count; i++)
            {
                T_Bom_Detail t_Bom_Detail = new T_Bom_Detail();
                t_Bom_Detail.F_Num         = int.Parse(bomTable.Rows[i]["零件数量"].ToString());
                t_Bom_Detail.F_Part_Code   = bomTable.Rows[i]["零件编码"].ToString();
                t_Bom_Detail.F_Bom_Id      = F_Id;
                t_Bom_Detail.F_Enable_Mark = 1;
                t_Bom_Detail.F_Create_Time = DateTime.Now;
                t_Bom_Detail.F_Create_By   = ManageProvider.Provider.Current().User.F_Account;
                insertBomDetailList.Add(t_Bom_Detail);
                //InsertId++;
            }
            using (var isOpenTrans = new Repository <T_Bom_Detail>().BeginTrans())
            {
                try
                {
                    if (t_product.F_Code != null && t_product.F_Name != null)
                    {
                        new RepositoryFactory <T_Product>().SubmitForm(t_product, isOpenTrans); //添加产品
                    }
                    new BomDetailBLL().Modify(F_Id, isOpenTrans);                               //修改详情
                    new BomDetailBLL().InsertFormBatch(insertBomDetailList, isOpenTrans);       //批量插入bom详情
                    new Repository <T_Bom_Detail>().Commit();
                    return(true);
                }
                catch (Exception)
                {
                    new Repository <T_Bom_Detail>().Rollback();
                    throw;
                }
                finally
                {
                    new Repository <T_Bom_Detail>().Close();
                }
            }
        }
Ejemplo n.º 13
0
        //  /api/Part/GetPartDetailCode?objcode=3304110405901634
        /// <summary>
        /// 根据标识码获取详情
        /// </summary>
        /// <param name="objcode"></param>
        /// <returns></returns>
        public bj_part GetPartDetailCode(string objcode)
        {
            PartBLL partBll = new PartBLL();

            return(partBll.GetPartDetailCode(objcode));
        }
Ejemplo n.º 14
0
        public void PartBLLConstructorTest1()
        {
            PartBLL target = new PartBLL();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }