public RedirectToRouteResult CreateGroupMatPost(Guid ID, FormCollection FC)
        {
            Guid LinkMainCID = ID;
            Material M = new Material();
            TryUpdateModel<Material>(M, FC);
            try
            {
                Guid MatID = IM.CreateBaseGroupMaterial(M, string.Empty, LinkMainCID);

                //产品创建成功,创建图片文件
                try
                {
                    HttpPostedFileBase MatImg = Request.Files["ImagePath"];
                    MyAlbumImageUpload MyMatImg = new MyAlbumImageUpload();
                    string[] ImgPath = MyMatImg.CreateMatImgProcess(MatImg, "MaterialImg/" + LinkMainCID.ToString());
                    IM.UpdateMaterialImg(MatID, ImgPath[0], ImgPath[1], ImgPath[2]);
                }
                catch
                {
                    //Dothing
                }

                try
                {
                    HttpPostedFileBase MatFile = Request.Files["FilePath"];
                    MyNormalUploadFile MyUpload = new MyNormalUploadFile();
                    string FilePath = MyUpload.NormalUpLoadFileProcess(MatFile, "MaterialFile/" + LinkMainCID.ToString());
                    IM.UpdateMatFilePath(MatID, FilePath);
                }
                catch
                {

                }
                return RedirectToAction("UpdateGroupMaterialBase", "Material", new { ID = MatID });
            }
            catch (Exception Ex)
            {
                TempData["Error"] = Ex.Message.ToString();
                TempData["MatName"] = M.MatName;
                TempData["MatSpecifications"] = M.MatSpecifications;
                TempData["MatBrand"] = M.MatBrand;
                TempData["MatManufacturerSn"] = M.MatManufacturerSn;
                TempData["MatUnit"] = M.MatUnit;
                TempData["MatSummary"] = M.MatSummary;
                return RedirectToAction("CreateGroupMatPost", "Material", new { ID = ID });
            }
        }
        public RedirectToRouteResult MaterialFileUpLoadPost(Guid ID, Guid LinkMainCID)
        {
            try
            {
                HttpPostedFileBase MatFile = Request.Files["FilePath"];
                MyNormalUploadFile MyUpload = new MyNormalUploadFile();
                string FilePath = MyUpload.NormalUpLoadFileProcess(MatFile, "MaterialFile/" + LinkMainCID.ToString());
                IM.UpdateMatFilePath(ID, FilePath);
            }
            catch (Exception Ex)
            {
                TempData["Error"] = Ex.Message.ToString();
            }

            return RedirectToAction("MaterialImgAndFileUpload", "Material", new { ID = ID });
        }
        public List<MatExcel> InputMaterialByPurPriceAndLeadTimeExcel(HttpPostedFileBase ExcelFile, Guid LinkMainCID)
        {
            MyNormalUploadFile MF = new MyNormalUploadFile();
            //创建上传文件
            string ExcelFilePath = MF.NormalUpLoadFileProcess(ExcelFile, "Excel");

            //根据路径通过已存在的excel来创建HSSFWorkbook,即整个excel文档
            XSSFWorkbook workbook = new XSSFWorkbook(new FileStream(HttpRuntime.AppDomainAppPath.ToString() + ExcelFilePath, FileMode.Open, FileAccess.Read));

            //获取excel的第一个sheet
            ISheet sheet = workbook.GetSheetAt(0);

            List<MatExcel> ML = new List<MatExcel>();
            MatExcel M = new MatExcel();

            int Seconds = 0;

            for (int i = sheet.FirstRowNum; i <= sheet.LastRowNum; i++)
            {
                Seconds = Seconds + 1;
                IRow row = sheet.GetRow(i);
                M = M = new MatExcel();

                try
                {
                    M.MatID = new Guid(row.GetCell(0).ToString().Trim());
                }
                catch
                {
                    M.MatID = Guid.Empty;
                }

                try
                {
                    M.MatSn = row.GetCell(2).ToString().Trim();
                }
                catch
                {
                    M.MatSn = string.Empty;
                }

                try
                {
                    M.MatName = row.GetCell(3).ToString().Trim();
                }
                catch
                {
                    M.MatName = string.Empty;
                }

                try
                {
                    M.MatSpecifications = row.GetCell(4).ToString().Trim();
                }
                catch
                {
                    M.MatSpecifications = string.Empty;
                }

                try
                {
                    M.MatBrand = row.GetCell(5).ToString().Trim();
                }
                catch
                {
                    M.MatBrand = string.Empty;
                }

                try
                {
                    M.MatManufacturerSn = row.GetCell(6).ToString().Trim();
                }
                catch
                {
                    M.MatManufacturerSn = string.Empty;
                }

                try
                {
                    M.MatUnit = row.GetCell(7).ToString().Trim();
                }
                catch
                {
                    M.MatUnit = string.Empty;
                }

                try
                {
                    M.CostPrice = Convert.ToDecimal(row.GetCell(8).ToString().Trim());
                }
                catch
                {
                    M.CostPrice = 0;
                }

                try
                {
                    M.MarketPrice = Convert.ToDecimal(row.GetCell(9).ToString().Trim());
                }
                catch
                {
                    M.MarketPrice = 0;
                }

                try
                {
                    M.LeadTime = Convert.ToInt32(row.GetCell(10).ToString().Trim());
                }
                catch
                {
                    M.LeadTime = 0;
                }

                try
                {
                    M.SupplierName = row.GetCell(11).ToString().Trim();
                }
                catch
                {
                    M.SupplierName = string.Empty;
                }

                M.IsErrorMatInfo = 0;
                M.IsErrorMatSn = 0;

                if (Seconds > 1 && Seconds <= 4001 && M.MatID != Guid.Empty && !string.IsNullOrEmpty(M.MatName))
                {
                    ML.Add(M);
                }
            }
            return ML;
        }
        public void InputMaterialByExcel(HttpPostedFileBase ExcelFile, Guid LinkMainCID)
        {
            MyNormalUploadFile MF = new MyNormalUploadFile();
            //创建上传文件
            string ExcelFilePath = MF.NormalUpLoadFileProcess(ExcelFile, "Excel");

            //根据路径通过已存在的excel来创建HSSFWorkbook,即整个excel文档
            XSSFWorkbook workbook = new XSSFWorkbook(new FileStream(HttpRuntime.AppDomainAppPath.ToString() + ExcelFilePath, FileMode.Open, FileAccess.Read));

            //获取excel的第一个sheet
            ISheet sheet = workbook.GetSheetAt(0);

            List<MatExcel> ML = new List<MatExcel>();
            MatExcel M = new MatExcel();

            int Seconds = 0;

            for (int i = sheet.FirstRowNum; i <= sheet.LastRowNum; i++)
            {
                Seconds = Seconds + 1;
                IRow row = sheet.GetRow(i);
                M = M = new MatExcel();

                try
                {
                    M.MatSn = row.GetCell(0).ToString().Trim();
                }
                catch
                {
                    M.MatSn = string.Empty;
                }

                try
                {
                    M.MatName = row.GetCell(1).ToString().Trim();
                }
                catch
                {
                    M.MatName = string.Empty;
                }

                try
                {
                    M.MatSpecifications = row.GetCell(2).ToString().Trim();
                }
                catch
                {
                    M.MatSpecifications = string.Empty;
                }

                try
                {
                    M.MatManufacturerSn = row.GetCell(3).ToString().Trim();
                }
                catch
                {
                    M.MatManufacturerSn = string.Empty;
                }

                try
                {
                    M.MatBrand = row.GetCell(4).ToString().Trim();
                }
                catch
                {
                    M.MatBrand = string.Empty;
                }

                try
                {
                    M.MatBrandType = row.GetCell(5).ToString().Trim();
                }
                catch
                {
                    M.MatBrandType = string.Empty;
                }

                try
                {
                    M.MatUnit = row.GetCell(6).ToString().Trim();
                }
                catch
                {
                    M.MatUnit = string.Empty;
                }

                try
                {
                    M.CostPrice = Convert.ToDecimal(row.GetCell(7).ToString().Trim());
                }
                catch
                {
                    M.CostPrice = 0;
                }

                try
                {
                    M.MarketPrice = Convert.ToDecimal(row.GetCell(8).ToString().Trim());
                }
                catch
                {
                    M.MarketPrice = 0;
                }

                try
                {
                    M.LeadTime = Convert.ToInt32(row.GetCell(9).ToString().Trim());
                }
                catch
                {
                    M.LeadTime = 0;
                }

                try
                {
                    M.MatSummary = row.GetCell(10).ToString().Trim();
                }
                catch
                {
                    M.MatSummary = string.Empty;
                }

                if (Seconds > 1 && Seconds <= 1001 && !string.IsNullOrEmpty(M.MatName) && !string.IsNullOrEmpty(M.MatUnit) && !string.IsNullOrEmpty(M.MatBrand))
                {
                    ML.Add(M);
                }
            }

            ////删除持久化内容
            try {
                db.MatExcelDB.Remove(db.MatExcelDB.Find(LinkMainCID));
                db.SaveChanges();
            }
            catch
            {
                //Dothing
            }

            //存储进入持久化Json数据
            string JSONStr = JsonConvert.SerializeObject(ML);
            MatExcelDB MExcel = new MatExcelDB();
            MExcel.LinkMainCID = LinkMainCID;
            MExcel.MatListJson = JSONStr;
            db.MatExcelDB.Add(MExcel);
            db.SaveChanges();
        }