Exemplo n.º 1
0
        public ActionResult EditForTask(TND_TASKASSIGN taskassign)
        {
            log.Info("update task assign:task_id=" + taskassign.TASK_ID);
            string message = "";
            TnderProjectService service = new TnderProjectService();
            SYS_USER            u       = UtilService.GetUserInfoFromSession(Session);

            taskassign.MODIFY_ID   = u.USER_ID;
            taskassign.MODIFY_DATE = DateTime.Now;
            if (taskassign.FINISH_DATE.ToString() == "")
            {
                taskassign.FINISH_DATE = DateTime.Now;
            }
            //當任務類型無輸入值時,將View返回頁面同時帶入錯誤訊息
            if (taskassign.TASK_TYPE == null)
            {
                log.Info("updates fail");
                ViewBag.ErrorMessage = "修改不成功,請重新輸入任務類型,此欄位不可為空白!!";
                return(View(taskassign));
            }
            service.updateTask(taskassign);
            message        = "任務分派資料修改成功,任務類型為 " + taskassign.TASK_TYPE;
            ViewBag.result = message;
            return(View(taskassign));
        }
Exemplo n.º 2
0
        public ActionResult Logout()
        {
            SYS_USER u = UtilService.GetUserInfoFromSession(Session);

            log.Info(u.USER_ID + " Logout!!");
            Session.Clear();//["UserService"] = null;
            return(View("Index"));
        }
Exemplo n.º 3
0
        public ActionResult Task(string id)
        {
            log.Info("task assign page!!");
            ViewBag.projectid = id;
            TnderProjectService service = new TnderProjectService();
            TND_PROJECT         p       = service.getProjectById(id);

            ViewBag.projectName = p.PROJECT_NAME;
            SYS_USER u = UtilService.GetUserInfoFromSession(Session);

            ViewBag.createid = u.USER_ID;
            return(View());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 上載現有標單資料
        /// </summary>
        public string uploadProjectItem(HttpPostedFileBase file1)
        {
            string projectid = Request["id"];

            log.Debug("ProjectID=" + projectid + ",Upload ProjectItem=" + file1.FileName);
            TnderProjectService service = new TnderProjectService();

            service.getProjectById(projectid);
            SYS_USER u = UtilService.GetUserInfoFromSession(Session);

            if (null != file1 && file1.ContentLength != 0)
            {
                try
                {
                    //2.解析Excel
                    log.Info("Parser Excel data:" + file1.FileName);
                    //2.1 將上傳檔案存檔
                    var fileName = Path.GetFileName(file1.FileName);
                    var path     = Path.Combine(ContextService.strUploadPath + "/" + projectid, fileName);
                    log.Info("save excel file:" + path);
                    file1.SaveAs(path);
                    //2.2 解析Excel 檔案
                    //poiservice.ConvertDataForTenderProject(prj.PROJECT_ID, (int)prj.START_ROW_NO);
                    ProjectItem2Excel poiservice = new ProjectItem2Excel();
                    poiservice.InitializeWorkbook(path);
                    poiservice.ConvertDataForTenderProject(projectid);
                    //2.3 記錄錯誤訊息
                    //        < 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 Project_Item  By Project ID");
                    service.delAllItemByProject();
                    //2.5
                    log.Info("Add All Project_ITEM to DB");
                    service.refreshProjectItem(poiservice.lstProjectItem);
                }
                catch (Exception ex)
                {
                    log.Error(ex.StackTrace);
                    return(ex.Message);
                }
            }
            if (service.strMessage != null)
            {
                return(service.strMessage);
            }
            else
            {
                return("匯入成功!!");
            }
        }
Exemplo n.º 5
0
        //更新任務分派資料
        public String refreshTaskItem(FormCollection form)
        {
            log.Info("form:" + form.Count);
            string         msg  = "修改任務分派資料成功!!";
            TND_TASKASSIGN item = new TND_TASKASSIGN();

            item.PROJECT_ID = form["prjid"];
            if (null != form["task_id"] && form["task_id"] != "")
            {
                item.TASK_ID = Int64.Parse(form["task_id"]);
            }
            item.USER_ID   = form["userId"];
            item.TASK_TYPE = form["taskType"];
            item.TASK_ITEM = form["taskItem"];
            item.REMARK    = form["taskRemark"];
            if (null != form["finishDate"] && form["finishDate"] != "")
            {
                item.FINISH_DATE = Convert.ToDateTime(form.Get("finishDate"));
            }

            item.CREATE_DATE = DateTime.Now;
            UserService us = new UserService();
            SYS_USER    u  = UtilService.GetUserInfoFromSession(Session);

            item.CREATE_ID   = u.USER_ID;
            item.MODIFY_ID   = u.USER_ID;
            item.MODIFY_DATE = DateTime.Now;
            TnderProjectService service = new TnderProjectService();
            int i = service.updateTask(item);

            if (i == 0)
            {
                msg = service.message;
            }
            return(msg);
        }
Exemplo n.º 6
0
        //新增任務分派資料
        public String AddTaskAssign(FormCollection form)
        {
            log.Info("form:" + form.Count);
            string         msg     = "新增任務分派資料成功!!";
            TND_TASKASSIGN leader  = new TND_TASKASSIGN();
            TND_TASKASSIGN costing = new TND_TASKASSIGN();
            TND_TASKASSIGN map     = new TND_TASKASSIGN();

            leader.PROJECT_ID  = form["project_id"];
            costing.PROJECT_ID = form["project_id"];
            map.PROJECT_ID     = form["project_id"];
            leader.TASK_TYPE   = "主辦";
            costing.TASK_TYPE  = "成控";
            map.TASK_TYPE      = "圖算";
            if (form["leader_user_id"] != "")
            {
                leader.USER_ID = form["leader_user_id"];
            }
            if (form["leader_task_item"] != "")
            {
                leader.TASK_ITEM = form["leader_task_item"];
            }
            if (form["leader_remark"] != "")
            {
                leader.REMARK = form["leader_remark"];
            }
            if (form["leader_finish_date"] != "")
            {
                leader.FINISH_DATE = Convert.ToDateTime(form.Get("leader_finish_date"));
            }
            if (form["costing_user_id"] != "")
            {
                costing.USER_ID = form["costing_user_id"];
            }
            if (form["costing_task_item"] != "")
            {
                costing.TASK_ITEM = form["costing_task_item"];
            }
            if (form["costing_remark"] != "")
            {
                costing.REMARK = form["costing_remark"];
            }
            if (form["costing_finish_date"] != "")
            {
                costing.FINISH_DATE = Convert.ToDateTime(form.Get("costing_finish_date"));
            }
            if (form["map_user_id"] != "")
            {
                map.USER_ID = form["map_user_id"];
            }
            if (form["map_task_item"] != "")
            {
                map.TASK_ITEM = form["map_task_item"];
            }
            if (form["map_remark"] != "")
            {
                map.REMARK = form["map_remark"];
            }
            if (form["map_finish_date"] != "")
            {
                map.FINISH_DATE = Convert.ToDateTime(form.Get("map_finish_date"));
            }
            UserService us    = new UserService();
            SYS_USER    u     = UtilService.GetUserInfoFromSession(Session);
            SYS_USER    uInfo = us.GetUserInfo(u.USER_ID);

            leader.CREATE_ID    = uInfo.USER_ID;
            leader.CREATE_DATE  = DateTime.Now;
            costing.CREATE_ID   = uInfo.USER_ID;
            costing.CREATE_DATE = DateTime.Now;
            map.CREATE_ID       = uInfo.USER_ID;
            map.CREATE_DATE     = DateTime.Now;
            List <TND_TASKASSIGN> taskAssign = new List <TND_TASKASSIGN>();

            taskAssign.Add(leader);
            taskAssign.Add(costing);
            taskAssign.Add(map);
            TnderProjectService service = new TnderProjectService();
            int i = service.refreshTask(taskAssign);

            if (i == 0)
            {
                msg = service.message;
            }
            return(msg);
        }
Exemplo n.º 7
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"));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 新增或更新Project_item 資料
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public String addProjectItem(FormCollection form)
        {
            log.Info("form:" + form.Count);
            string msg = "更新成功!!";

            TND_PROJECT_ITEM item = new TND_PROJECT_ITEM();

            item.PROJECT_ID      = form["project_id"];
            item.PROJECT_ITEM_ID = form["project_item_id"];
            item.ITEM_ID         = form["item_id"];
            item.ITEM_DESC       = form["item_desc"];
            item.ITEM_UNIT       = form["item_unit"];
            try
            {
                item.ITEM_QUANTITY = decimal.Parse(form["item_quantity"]);
            }
            catch (Exception ex)
            {
                log.Error(item.PROJECT_ITEM_ID + " not quattity:" + ex.Message);
            }
            try
            {
                item.ITEM_UNIT_PRICE = decimal.Parse(form["item_unit_price"]);
            }
            catch (Exception ex)
            {
                log.Error(item.PROJECT_ITEM_ID + " not unit price:" + ex.Message);
            }
            item.ITEM_REMARK = form["item_remark"];
            if (form["type_code_1"].Trim() != "")
            {
                item.TYPE_CODE_1 = form["type_code_1"];
            }
            else
            {
                item.TYPE_CODE_1 = null;
            }

            if (form["type_code_2"].Trim() != "")
            {
                item.TYPE_CODE_2 = form["type_code_2"];
            }
            else
            {
                item.TYPE_CODE_2 = null;
            }

            item.SYSTEM_MAIN = form["system_main"];
            item.SYSTEM_SUB  = form["system_sub"];
            item.DEL_FLAG    = form["selDelFlag"];
            try
            {
                item.EXCEL_ROW_ID = long.Parse(form["excel_row_id"]);
            }
            catch (Exception ex)
            {
                log.Error(item.PROJECT_ITEM_ID + " not exce row id:" + ex.Message);
            }

            SYS_USER loginUser = UtilService.GetUserInfoFromSession(Session);

            item.MODIFY_USER_ID = loginUser.USER_ID;
            item.MODIFY_DATE    = DateTime.Now;
            InquiryFormService service = new InquiryFormService();
            int    i       = 0;
            string strFlag = form["flag"].Trim();

            if (strFlag.Equals("addAfter"))
            {
                i = service.addProjectItemAfter(item);
            }
            else
            {
                i = service.updateProjectItem(item);
            }

            if (i == 0)
            {
                msg = service.message;
            }
            return(msg);
        }
Exemplo n.º 9
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));
        }