public IActionResult ParameterChangeOrderNo(Int64 ParameterID1, Int64 ParameterID2, int OrderNo1, int OrderNo2)
        {
            ExcelHepler Helper   = new ExcelHepler(_hostingEnvironment);
            string      userId   = _userManager.GetUserId(HttpContext.User);
            string      userName = HttpContext.User.Identity.Name;

            ParameterService parameterService = new ParameterService(_context);
            FileService      FileService      = new FileService(_hostingEnvironment, _context);

            PDC_Parameter item1 = parameterService.GetParameterOne(ParameterID1);
            PDC_Parameter item2 = parameterService.GetParameterOne(ParameterID2);

            string ErrorMsg = string.Empty;

            item1.OrderNo      = OrderNo1;
            item1.Modifyer     = userId;
            item1.ModifyerName = userName;
            item1.ModifyerDate = DateTime.Now;
            parameterService.UpdateParameter(item1, ref ErrorMsg);


            item2.OrderNo      = OrderNo2;
            item2.Modifyer     = userId;
            item2.ModifyerName = userName;
            item2.ModifyerDate = DateTime.Now;
            parameterService.UpdateParameter(item2, ref ErrorMsg);



            return(Json(ErrorMsg));
        }
        public IActionResult UploadWorkDetail(string ParameterText, string ParameterValue, IFormFile file)
        {
            ParameterService parameterService = new ParameterService(_context);
            FileService      FileService      = new FileService(_hostingEnvironment, _context);
            string           ErrorMsg         = string.Empty;
            string           userId           = _userManager.GetUserId(HttpContext.User);
            string           userName         = HttpContext.User.Identity.Name;

            PDC_File      newFile = new PDC_File();
            PDC_Parameter item    = parameterService.GetParameterOne("ConfigurationWorkDetail");

            if (file.Length > 0)
            {
                PDC_File WorkDetail_File = FileService.GetFileList("ConfigurationWorkDetail", item.ParameterID).FirstOrDefault();

                if (WorkDetail_File != null)
                {
                    FileService.FileRemove(WorkDetail_File.FileID);
                }

                FileService.FileAdd(file, "ConfigurationWorkDetail", userId, userName, out newFile, item.ParameterID);
            }

            item.ParameterText  = ParameterText;
            item.ParameterValue = ParameterValue;
            item.Modifyer       = userId;
            item.ModifyerName   = userName;
            item.ModifyerDate   = DateTime.Now;

            parameterService.UpdateParameter(item, ref ErrorMsg);

            return(Json(new { ErrorMsg = ErrorMsg, File = newFile }));
        }
        public IActionResult UploadProjectTime(string ApplyDrawText, string SendReturnText, string ReleaseText, string RejectText)
        {
            ParameterService parameterService = new ParameterService(_context);
            string           userId           = _userManager.GetUserId(HttpContext.User);
            string           userName         = HttpContext.User.Identity.Name;

            string ErrorMsg = string.Empty;

            PDC_Parameter ApplyDrawitem = parameterService.GetParameterOne("ConfigurationApplyDraw");

            ApplyDrawitem.ParameterText = ApplyDrawText;
            ApplyDrawitem.Modifyer      = userId;
            ApplyDrawitem.ModifyerName  = userName;
            ApplyDrawitem.ModifyerDate  = DateTime.Now;

            PDC_Parameter SendReturnitem = parameterService.GetParameterOne("ConfigurationSendReturn");

            SendReturnitem.ParameterText = SendReturnText;
            SendReturnitem.Modifyer      = userId;
            SendReturnitem.ModifyerName  = userName;
            SendReturnitem.ModifyerDate  = DateTime.Now;

            PDC_Parameter Releaseitem = parameterService.GetParameterOne("ConfigurationRelease");

            Releaseitem.ParameterText = ReleaseText;
            Releaseitem.Modifyer      = userId;
            Releaseitem.ModifyerName  = userName;
            Releaseitem.ModifyerDate  = DateTime.Now;

            PDC_Parameter Rejectitem = parameterService.GetParameterOne("ConfigurationReject");

            Rejectitem.ParameterText = RejectText;
            Rejectitem.Modifyer      = userId;
            Rejectitem.ModifyerName  = userName;
            Rejectitem.ModifyerDate  = DateTime.Now;

            parameterService.UpdateParameter(ApplyDrawitem, ref ErrorMsg);
            parameterService.UpdateParameter(SendReturnitem, ref ErrorMsg);
            parameterService.UpdateParameter(Releaseitem, ref ErrorMsg);
            parameterService.UpdateParameter(Rejectitem, ref ErrorMsg);

            return(Json(ErrorMsg));
        }
        public IActionResult SearchPCB(Int64 ParameterID)
        {
            m_ConfigurationPartial model            = new m_ConfigurationPartial();
            ParameterService       parameterService = new ParameterService(_context);


            model.m_PCBParameter = parameterService.GetParameterOne(ParameterID);
            model.PCBFileList    = _context.PDC_File.Where(x => x.SourceID == ParameterID && x.FunctionName == "Configuration_PCBFile").ToList();

            return(Json(model));
        }
        public IActionResult SavePCB(Int64 ParameterID, string ParameterDesc)
        {
            ParameterService parameterService = new ParameterService(_context);
            string           userId           = _userManager.GetUserId(HttpContext.User);
            string           userName         = HttpContext.User.Identity.Name;

            PDC_Parameter m_PCBParameter = parameterService.GetParameterOne(ParameterID);

            string ErrorMsg = string.Empty;

            m_PCBParameter.ParameterDesc = ParameterDesc;
            m_PCBParameter.Modifyer      = userId;
            m_PCBParameter.ModifyerName  = userName;
            m_PCBParameter.ModifyerDate  = DateTime.Now;
            parameterService.UpdateParameter(m_PCBParameter, ref ErrorMsg);

            return(Json(ErrorMsg));
        }
        //consume custom security service to get all roles
        public IActionResult Index()
        {
            m_ConfigurationPartial model            = new m_ConfigurationPartial();
            ParameterService       parameterService = new ParameterService(_context);
            FileService            FileService      = new FileService(_hostingEnvironment, _context);

            var user = _userManager.GetUserId(HttpContext.User);

            //組態設定-CNS範本
            if (_context.PDC_File.Where(x => x.FunctionName == "ConfigurationSample").Any())
            {
                model.CNS_Sample = _context.PDC_File.Where(x => x.FunctionName == "ConfigurationSample").OrderByDescending(x => x.CreatorDate).FirstOrDefault();
            }
            //組態設定-首頁連結
            model.HomeLinkList     = parameterService.GetParameterList("Configuration_HomeLink");
            model.HomeLinkFileList = _context.PDC_File.Where(x => x.FunctionName == "Configuration_HomeLink").ToList();

            //組態設定-圖文說明
            model.PCBTypeList = parameterService.GetSelectList("PCBLayoutConstraint");
            if (model.PCBTypeList.Any())
            {
                model.PCBTypeItemList = parameterService.GetSelectList(Convert.ToInt64(model.PCBTypeList.First().Value));
            }

            //組態設定-清單與罐頭
            model.PCBParameterList = parameterService.GetSelectList("PCBTypeList");
            //組態設定-其他
            model.Announcement    = parameterService.GetParameterOne("ConfigurationAnnouncement");
            model.Description     = parameterService.GetParameterOne("ConfigurationDescription");
            model.ApplyDraw       = parameterService.GetParameterOne("ConfigurationApplyDraw");
            model.SendReturn      = parameterService.GetParameterOne("ConfigurationSendReturn");
            model.Release         = parameterService.GetParameterOne("ConfigurationRelease");
            model.Reject          = parameterService.GetParameterOne("ConfigurationReject");
            model.FormApply       = parameterService.GetParameterOne("ConfigurationFormApply");
            model.WorkDetail      = parameterService.GetParameterOne("ConfigurationWorkDetail");
            model.WorkDetail_File = FileService.GetFileList("ConfigurationWorkDetail", model.WorkDetail.ParameterID).FirstOrDefault();

            model.SystemCategoryList = parameterService.GetSelectList("SystemCategory", false);

            return(View(model));
        }
        public IActionResult UploadDescription(string ParameterText)
        {
            ParameterService parameterService = new ParameterService(_context);

            string userId   = _userManager.GetUserId(HttpContext.User);
            string userName = HttpContext.User.Identity.Name;

            string ErrorMsg = string.Empty;

            PDC_Parameter item = parameterService.GetParameterOne("ConfigurationDescription");

            item.ParameterText = ParameterText;
            item.Modifyer      = userId;
            item.ModifyerName  = userName;
            item.ModifyerDate  = DateTime.Now;

            parameterService.UpdateParameter(item, ref ErrorMsg);

            return(Json(ErrorMsg));
        }