Beispiel #1
0
        //上傳廠商報價單
        public string FileUpload(HttpPostedFileBase file)
        {
            log.Info("Upload form from supplier:" + Request["projectid"]);
            string projectid = Request["projectid"];
            string iswage    = "N";

            if (null != Request["isWage"])
            {
                log.Debug("isWage:" + Request["isWage"]);
                iswage = "Y";
            }
            int i = 0;

            //上傳至廠商報價單目錄
            if (null != file && file.ContentLength != 0)
            {
                var    fileName = Path.GetFileName(file.FileName);
                string dir      = ContextService.strUploadPath + "/" + projectid + "/" + ContextService.quotesFolder;
                ZipFileCreator.CreateDirectory(dir);
                var path = Path.Combine(dir, fileName);
                file.SaveAs(path);
                log.Info("Parser Excel File Begin:" + file.FileName);
                InquiryFormToExcel quoteFormService = new InquiryFormToExcel();
                try
                {
                    quoteFormService.convertInquiry2Project(path, projectid, iswage);
                }
                catch (Exception ex)
                {
                    log.Error(ex.StackTrace);
                }
                //如果詢價單編號為空白,新增詢價單資料,否則更新相關詢價單資料-new
                log.Debug("Parser Excel File Finish!");
                if (null != quoteFormService.form.FORM_ID && quoteFormService.form.FORM_ID != "")
                {
                    log.Info("Update Form for Inquiry:" + quoteFormService.form.FORM_ID);
                    i = service.refreshSupplierForm(quoteFormService.form.FORM_ID, quoteFormService.form, quoteFormService.formItems);
                }
                else
                {
                    log.Info("Create New Form for Inquiry:");
                    i = service.createInquiryFormFromSupplier(quoteFormService.form, quoteFormService.formItems);
                }
                log.Info("add supplier form record count=" + i);
            }
            if (i == -1)
            {
                return("檔案匯入失敗!!");
            }
            else
            {
                return("檔案匯入成功!!");
            }
        }
        //儲存日報數量紀錄
        public void saveItemRow(FormCollection f)
        {
            SYS_USER u = (SYS_USER)Session["user"];

            log.Debug("projectId=" + Request["txtProjectId"] + ",prjUid=" + Request["txtPrjUid"] + ",ReportId=" + Request["reportID"]);
            log.Debug("form Data ItemId=" + Request["planItemId"]);
            log.Debug("form Data Qty=planItemQty" + Request["planItemQty"]);

            string projectid      = Request["txtProjectId"];
            int    prjuid         = int.Parse(Request["txtPrjUid"]);
            string strWeather     = Request["selWeather"];
            string strSummary     = Request["txtSummary"];
            string strSenceUser   = Request["txtSenceUser"];
            string strSupervision = Request["txtSupervision"];
            string strOwner       = Request["txtOwner"];
            string strRptDate     = Request["reportDate"];

            DailyReport newDailyRpt = new DailyReport();

            PLAN_DALIY_REPORT RptHeader = new PLAN_DALIY_REPORT();

            RptHeader.PROJECT_ID       = projectid;
            RptHeader.WEATHER          = strWeather;
            RptHeader.SUMMARY          = strSummary;
            RptHeader.SCENE_USER_NAME  = strSenceUser;
            RptHeader.SUPERVISION_NAME = strSupervision;
            RptHeader.OWNER_NAME       = strOwner;
            newDailyRpt.dailyRpt       = RptHeader;
            RptHeader.REPORT_DATE      = DateTime.Parse(strRptDate);
            //取得日報編號
            SerialKeyService snService = new SerialKeyService();

            if (null == Request["reportID"] || "" == Request["reportID"])
            {
                RptHeader.REPORT_ID      = snService.getSerialKey(planService.KEY_ID);
                RptHeader.CREATE_DATE    = DateTime.Now;
                RptHeader.CREATE_USER_ID = u.USER_ID;
            }
            else
            {
                RptHeader.REPORT_ID      = Request["ReportID"];
                RptHeader.CREATE_DATE    = DateTime.Parse(Request["txtCreateDate"]);
                RptHeader.CREATE_USER_ID = Request["txtCreateUserId"];
                RptHeader.MODIFY_DATE    = DateTime.Now;
                RptHeader.MODIFY_USER_ID = u.USER_ID;
            }

            //建立專案任務資料 (結構是支援多項任務,僅先使用一筆)
            newDailyRpt.lstRptTask = new List <PLAN_DR_TASK>();
            PLAN_DR_TASK RptTask = new PLAN_DR_TASK();

            RptTask.PROJECT_ID = projectid;
            RptTask.PRJ_UID    = prjuid;
            RptTask.REPORT_ID  = RptHeader.REPORT_ID;
            newDailyRpt.lstRptTask.Add(RptTask);
            //處理料件
            newDailyRpt.lstRptItem = new List <PLAN_DR_ITEM>();
            if (null != Request["planItemId"])
            {
                string[] aryPlanItem      = Request["planItemId"].Split(',');
                string[] aryPlanItemQty   = Request["planItemQty"].Split(',');
                string[] aryAccumulateQty = Request["accumulateQty"].Split(',');

                log.Debug("count ItemiD=" + aryPlanItem.Length + ",qty=" + aryPlanItemQty.Length);
                newDailyRpt.lstRptItem = new List <PLAN_DR_ITEM>();
                for (int i = 0; i < aryPlanItem.Length; i++)
                {
                    PLAN_DR_ITEM item = new PLAN_DR_ITEM();
                    item.PLAN_ITEM_ID = aryPlanItem[i];
                    item.PROJECT_ID   = projectid;
                    item.REPORT_ID    = RptHeader.REPORT_ID;
                    if ("" != aryPlanItemQty[i])
                    {
                        item.FINISH_QTY = decimal.Parse(aryPlanItemQty[i]);
                    }
                    if ("" != aryAccumulateQty[i])
                    {
                        item.LAST_QTY = decimal.Parse(aryAccumulateQty[i]);
                    }
                    newDailyRpt.lstRptItem.Add(item);
                }
            }
            //處理出工資料
            newDailyRpt.lstWokerType4Show = new List <PLAN_DR_WORKER>();
            if (null != Request["txtSupplierId"])
            {
                ///出工廠商
                string[] arySupplier = Request["txtSupplierId"].Split(',');
                ///出工人數
                string[] aryWorkerQty = Request["txtWorkerQty"].Split(',');
                ///備註
                string[] aryRemark = Request["txtRemark"].Split(',');
                for (int i = 0; i < arySupplier.Length; i++)
                {
                    PLAN_DR_WORKER item = new PLAN_DR_WORKER();
                    item.REPORT_ID   = RptHeader.REPORT_ID;
                    item.SUPPLIER_ID = arySupplier[i];
                    log.Debug("Supplier Info=" + item.SUPPLIER_ID);
                    if ("" != aryWorkerQty[i].Trim())
                    {
                        item.WORKER_QTY = decimal.Parse(aryWorkerQty[i]);
                        newDailyRpt.lstWokerType4Show.Add(item);
                    }
                    item.REMARK = aryRemark[i];
                }
                log.Debug("count WorkerD=" + arySupplier.Length);
            }
            //處理點工資料
            newDailyRpt.lstTempWoker4Show = new List <PLAN_DR_TEMPWORK>();
            if (null != Request["txtTempWorkSupplierId"])
            {
                string[] aryTempSupplier       = Request["txtTempWorkSupplierId"].Split(',');
                string[] aryTempWorkerQty      = Request["txtTempWorkerQty"].Split(',');
                string[] aryTempChargeSupplier = Request["txtChargeSupplierId"].Split(',');
                string[] aryTempWarkRemark     = Request["txtTempWorkRemark"].Split(',');
                string[] aryDoc = Request["doc"].Split(',');
                for (int i = 0; i < aryTempSupplier.Length; i++)
                {
                    PLAN_DR_TEMPWORK item = new PLAN_DR_TEMPWORK();
                    item.REPORT_ID   = RptHeader.REPORT_ID;
                    item.SUPPLIER_ID = aryTempSupplier[i];
                    item.CHARGE_ID   = aryTempChargeSupplier[i];
                    ///處理工人名單檔案
                    log.Debug("File Count=" + Request.Files.Count);
                    if (Request.Files[i].ContentLength > 0)
                    {
                        //存檔路徑
                        var    fileName     = Path.GetFileName(Request.Files[i].FileName);
                        string reportFolder = ContextService.strUploadPath + "\\" + projectid + "\\DailyReport\\";
                        //check 資料夾是否存在
                        string folder = reportFolder + RptHeader.REPORT_ID;
                        ZipFileCreator.CreateDirectory(folder);
                        var path = Path.Combine(folder, fileName);
                        Request.Files[i].SaveAs(path);
                        item.DOC = "DailyReport\\" + RptHeader.REPORT_ID + "\\" + fileName;
                        log.Debug("Upload Sign List File:" + Request.Files[i].FileName);
                    }
                    else
                    {
                        item.DOC = aryDoc[i];
                        log.Error("Not Upload Sign List File!Exist File=" + item.DOC);
                    }
                    log.Debug("Supplier Info=" + item.SUPPLIER_ID);
                    if ("" != aryTempWorkerQty[i].Trim())
                    {
                        item.WORKER_QTY = decimal.Parse(aryTempWorkerQty[i]);
                        newDailyRpt.lstTempWoker4Show.Add(item);
                    }
                    item.REMARK = aryTempWarkRemark[i];
                }
            }
            //處理機具資料
            newDailyRpt.lstRptWorkerAndMachine = new List <PLAN_DR_WORKER>();
            string[] aryMachineType = f["MachineKeyid"].Split(',');
            string[] aryMachineQty  = f["planMachineQty"].Split(',');
            for (int i = 0; i < aryMachineType.Length; i++)
            {
                PLAN_DR_WORKER item = new PLAN_DR_WORKER();
                item.REPORT_ID   = RptHeader.REPORT_ID;
                item.WORKER_TYPE = "MACHINE";
                item.PARA_KEY_ID = aryMachineType[i];
                if ("" != aryMachineQty[i])
                {
                    item.WORKER_QTY = decimal.Parse(aryMachineQty[i]);
                    newDailyRpt.lstRptWorkerAndMachine.Add(item);
                }
            }
            log.Debug("count MachineD=" + f["MachineKeyid"] + ",WorkerQty=" + f["planMachineQty"]);
            //處理重要事項資料
            newDailyRpt.lstRptNote = new List <PLAN_DR_NOTE>();
            string[] aryNote = f["planNote"].Split(',');
            for (int i = 0; i < aryNote.Length; i++)
            {
                PLAN_DR_NOTE item = new PLAN_DR_NOTE();
                item.REPORT_ID = RptHeader.REPORT_ID;
                if ("" != aryNote[i].Trim())
                {
                    item.SORT   = i + 1;
                    item.REMARK = aryNote[i].Trim();
                    newDailyRpt.lstRptNote.Add(item);
                }
            }
            //註記任務是否完成
            if (null == Request["taskDone"])
            {
                newDailyRpt.isDoneFlag = false;
            }
            else
            {
                newDailyRpt.isDoneFlag = true;
            }
            log.Debug("count Note=" + f["planNote"]);
            string msg = planService.createDailyReport(newDailyRpt);

            Response.Redirect("~/ProjectPlan/dailyReport/" + projectid);
            //ProjectPlan/dailyReport/P00061
        }
Beispiel #3
0
        public ActionResult uploadPlanItem(TND_PROJECT prj, HttpPostedFileBase file)
        {
            //1.取得專案編號
            string projectid = Request["projectid"];

            log.Info("Upload plan items for projectid=" + projectid);
            TnderProjectService service = new TnderProjectService();
            SYS_USER            u       = UtilService.GetUserInfoFromSession(Session);
            string message = "";

            //修改專案狀態
            prj.PROJECT_ID       = projectid;
            prj.STATUS           = "專案執行";
            prj.PROJECT_NAME     = Request["projectname"];
            prj.ENG_NAME         = Request["engname"];
            prj.CONTRUCTION_NAME = Request["contructionname"];
            prj.LOCATION         = Request["location"];
            prj.OWNER_NAME       = Request["ownername"];
            prj.CONTACT_NAME     = Request["contactname"];
            prj.CONTACT_TEL      = Request["contecttel"];
            prj.CONTACT_FAX      = Request["contactfax"];
            prj.CONTACT_EMAIL    = Request["contactemail"];
            prj.DUE_DATE         = Convert.ToDateTime(Request["duedate"]);
            prj.SCHDL_OFFER_DATE = Convert.ToDateTime(Request["schdlofferdate"]);
            if (Request["starrowno"] != null || " " != Request["starrowno"])
            {
                prj.START_ROW_NO = int.Parse(Request["starrowno"]);
            }
            //prj.WAGE_MULTIPLIER = decimal.Parse(Request["wage"]);
            prj.EXCEL_FILE_NAME = Request["excelfilename"];
            prj.OWNER_USER_ID   = Request["owneruserid"];
            prj.CREATE_USER_ID  = Request["createdid"];
            prj.CREATE_DATE     = Convert.ToDateTime(Request["createddate"]);
            prj.MODIFY_USER_ID  = u.USER_ID;
            prj.MODIFY_DATE     = DateTime.Now;
            service.updateProject(prj);
            message = "專案進入執行階段:" + prj.PROJECT_ID + "<br/>";

            if (null != file && file.ContentLength != 0)
            {
                //2.解析Excel
                log.Info("Parser Excel data:" + file.FileName);
                //2.1 將上傳檔案存檔
                var fileName = Path.GetFileName(file.FileName);
                ZipFileCreator.CreateDirectory(ContextService.strUploadPath + "/" + projectid);
                var path = Path.Combine(ContextService.strUploadPath + "/" + projectid, fileName);
                log.Info("save excel file:" + path);
                file.SaveAs(path);
                //2.2 解析Excel 檔案
                ProjectItemFromExcel poiservice = new ProjectItemFromExcel();
                poiservice.InitializeWorkbook(path);
                poiservice.ConvertDataForPlan(projectid);
                //2.3 記錄錯誤訊息
                message = message + "得標標單品項:共" + poiservice.lstPlanItem.Count + "筆資料,";
                message = message + "<a target=\"_blank\" href=\"/Plan/ManagePlanItem?id=" + projectid + "\"> 標單明細檢視畫面單</a><br/>" + poiservice.errorMessage;
                //        < button type = "button" class="btn btn-primary" onclick="location.href='@Url.Action("ManagePlanItem","Plan", new { id = @Model.tndProject.PROJECT_ID})'; ">標單明細</button>
                //2.4
                log.Info("Delete PLAN_ITEM By Project ID");
                service.delAllItemByPlan();
                //2.5
                log.Info("Add All PLAN_ITEM to DB");
                service.refreshPlanItem(poiservice.lstPlanItem);
            }
            TempData["result"] = message;//Plan/ManagePlanItem/P00023
            //return RedirectToAction()
            return(RedirectToAction("ManagePlanItem/" + projectid, "Plan"));
        }
Beispiel #4
0
        public ActionResult Create(TND_PROJECT prj, HttpPostedFileBase file)
        {
            log.Info("create project process! project =" + prj.ToString());
            TnderProjectService service = new TnderProjectService();
            SYS_USER            u       = UtilService.GetUserInfoFromSession(Session);
            string message = "";

            //1.更新或新增專案基本資料
            if (prj.PROJECT_ID == "" || prj.PROJECT_ID == null)
            {
                //新增專案
                prj.CREATE_USER_ID = u.USER_ID;
                prj.OWNER_USER_ID  = u.USER_ID;
                prj.CREATE_DATE    = DateTime.Now;
                service.newProject(prj);
                message = "建立專案:" + service.project.PROJECT_ID + "<br/>";
            }
            else
            {
                //修改專案基本資料
                prj.MODIFY_USER_ID = u.USER_ID;
                prj.MODIFY_DATE    = DateTime.Now;
                service.updateProject(prj);
                message = "專案基本資料修改:" + prj.PROJECT_ID + "<br/>";
            }
            //若使用者有上傳標單資料,則增加標單資料
            if (null != file && file.ContentLength != 0)
            {
                //2.解析Excel
                log.Info("Parser Excel data:" + file.FileName);
                //2.1 設定Excel 檔案名稱
                prj.EXCEL_FILE_NAME = file.FileName;
                //2.2 將上傳檔案存檔
                var fileName = Path.GetFileName(file.FileName);
                ZipFileCreator.CreateDirectory(ContextService.strUploadPath + "/" + prj.PROJECT_ID);
                var path = Path.Combine(ContextService.strUploadPath + "/" + prj.PROJECT_ID, fileName);
                log.Info("save excel file:" + path);
                file.SaveAs(path);
                try
                {
                    //2.2 解析Excel 檔案
                    ProjectItemFromExcel poiservice = new ProjectItemFromExcel();
                    poiservice.InitializeWorkbook(path);
                    poiservice.ConvertDataForTenderProject(prj.PROJECT_ID, (int)prj.START_ROW_NO);

                    //2.3 記錄錯誤訊息
                    message = message + "標單品項:共" + poiservice.lstProjectItem.Count + "筆資料,";
                    message = message + "<a target=\"_blank\" href=\"/Tender/ManageProjectItem?id=" + prj.PROJECT_ID + "\"> 標單明細檢視畫面單</a><br/>" + poiservice.errorMessage;
                    //2.4
                    log.Info("Delete TND_PROJECT_ITEM By Project ID");
                    service.delAllItemByProject();
                    //2.5
                    log.Info("Add All TND_PROJECT_ITEM to DB");
                    service.refreshProjectItem(poiservice.lstProjectItem);
                }
                catch (Exception ex)
                {
                    log.Error("Error Message:" + ex.Message + "." + ex.StackTrace);
                    message = ex.Message;
                }
            }
            ViewBag.projectId = service.project.PROJECT_ID;
            ViewBag.result    = message;
            return(View(service.project));
        }