public ActionResult SelectProduct(Repair record) { var model = new RepairModel(); if (record.ProductID.HasValue) { model.SelectedProduct = ProductInfo.Get(UserID, Employee.ID, record.ProductID.Value, false, DbAction.Repair.Create); } model.Record = record; var login = Login.Get(UserID); model.Editable = login.Type == LoginType.Office || login.Username == "admin"; if (Request.IsAjaxRequest()) { return(Json(new { html = RenderPartialViewToString("SelectedProduct", model) }, JsonRequestBehavior.AllowGet)); } return(View(Views.Save, model)); }
public async Task <IActionResult> Repair(RepairModel model) { var endpointDevice = await _context.EndpointDevices .FirstOrDefaultAsync(m => m.Identifier == model.DeviceId); if (endpointDevice == null) { return(NotFound("Nie znaleziono urządzenia końcowego")); } if (endpointDevice.TestResult == TestResult.Pozytywny) { return(BadRequest("Urządzenie końcowe zawiera pozytywny wynik testu")); } endpointDevice.TestResult = TestResult.Pozytywny; _context.Entry(endpointDevice).State = EntityState.Modified; foreach (var component in model.ComponentModels) { var foundComponent = await _context.Components.FirstOrDefaultAsync(com => com.Identifier == component.ComponentIdentificator); if (foundComponent == null) { return(BadRequest("Nie znaleziono komponentu")); } if (foundComponent.AvailableAmount < component.Amount) { return(BadRequest("Brak wystarczającej ilości dostepnych komponentów")); } foundComponent.AvailableAmount -= component.Amount; _context.Entry(foundComponent).State = EntityState.Modified; } if ((await _context.SaveChangesAsync()) >= 0) { return(Ok()); } return(StatusCode(500)); }
// GET: Repairs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RepairModel repairModel = db.Repairs.Find(id); if (repairModel == null) { return(HttpNotFound()); } var cars = db.Owner.Where(u => u.Email == User.Identity.Name); int i = 0; foreach (OwnerModel s in cars) { i = s.ID; } ViewBag.CarID = new SelectList(db.Car.Where(u => u.OwnerID == i), "ID", "Brand"); return(View(repairModel)); }
public async Task <IViewComponentResult> InvokeAsync(string id) { RepairModel repair = _context.Repairs.Find(id); /* Get and set value for NotMapped fields. */ repair.DptName = _context.Departments.Find(repair.DptId).Name_C; repair.AccDptName = _context.Departments.Find(repair.AccDpt).Name_C; repair.CheckerName = _context.AppUsers.Find(repair.CheckerId).FullName; if (repair.AssetNo != null && repair.AssetNo != "") { string acc = new AssetModel().GetAccDate(repair.AssetNo); int accdat; if (Int32.TryParse(acc, out accdat)) { repair.AssetAccDate = DateTime.ParseExact(Convert.ToString(19110000 + accdat), "yyyyMMdd", null); } //var tempAsset = _context.Assets.Where(a => a.AssetNo == repair.AssetNo).FirstOrDefault(); //if(tempAsset != null) //{ // repair.AssetAccDate = tempAsset.AccDate; //} } if (!string.IsNullOrEmpty(repair.Building)) { int buildingId = Convert.ToInt32(repair.Building); repair.BuildingName = _context.Buildings.Find(buildingId).BuildingName; if (!string.IsNullOrEmpty(repair.Floor)) { repair.FloorName = _context.Floors.Find(buildingId, repair.Floor).FloorName; if (!string.IsNullOrEmpty(repair.Area)) { repair.AreaName = _context.Places.Find(buildingId, repair.Floor, repair.Area).PlaceName; } } } return(View(repair)); }
public ActionResult EditRepair() { int repairID = Int32.Parse(Request.Params["repID"]); // ค้นข้อมูลของรายการซ่อมเพื่อแก้ไข Database db = new Database(); RepairDAO rDAO = new RepairDAO(db); RepairModel lsRModel = rDAO.FindById(repairID); db.Close(); ViewData["REPAIR"] = lsRModel; // รายการประเภทสินค้า db = new Database(); ProductTypeDAO ptDAO = new ProductTypeDAO(db); List <ProductTypeModel> lPTModel = ptDAO.FindAll(); db.Close(); ViewData["PRODUCTTYPE"] = lPTModel; // รายการยี่ห้อสินค้า db = new Database(); ProductDAO pDAO = new ProductDAO(db); List <ProductModel> pModel = pDAO.FindByTypeID(lsRModel.PRODUCT.TYPE.PRO_TYP_ID); db.Close(); ViewData["BRAND"] = pModel; //รายการผู้รับผิดชอบ db = new Database(); UsersDAO uDAO = new UsersDAO(db); List <UsersModel> uModel = uDAO.FindAll(); db.Close(); ViewData["STAFF"] = uModel; return(View()); }
public async Task <IViewComponentResult> InvokeAsync(string id) { RepairModel repair = _context.BMEDRepairs.Find(id); /* Get and set value for NotMapped fields. */ repair.DptName = _context.Departments.Find(repair.DptId).Name_C; repair.AccDptName = _context.Departments.Find(repair.AccDpt).Name_C; repair.CheckerName = _context.AppUsers.Find(repair.CheckerId).FullName; if (repair.AssetNo != null) { var asset = _context.BMEDAssets.Find(repair.AssetNo); if (asset != null) { if (asset.AccDate.HasValue) { repair.AssetAccDate = asset.AccDate.Value.ToString("yyyy/MM/dd"); } } } return(View(repair)); }
//REPAIRS public bool AddOrEditRepair(RepairModel newRepair) { if (newRepair.id_usterki == null) { return(false); //This repair is not connected to any fault - kinda useless. } try { using (var ctx = new DBProjectEntities()) { var repair = ctx.Naprawy.Find(newRepair.id_naprawy); if (repair == null) //DB did not find any record like provided one. Add it. { repair = ModelMapper.Mapper.Map <Naprawy>(newRepair); ctx.Naprawy.Add(repair); } else//There's a record that contains the residence already - modify it. { repair.id_naprawy = newRepair.id_naprawy; repair.data_rozpoczecia = newRepair.data_rozpoczecia; repair.data_ukonczenia = newRepair.data_ukonczenia; repair.data_zlecenia = newRepair.data_zlecenia; repair.id_firmy = newRepair.id_firmy; repair.id_usterki = repair.id_usterki; repair.stan = newRepair.stan; } ctx.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } return(true); }
public IActionResult Edit(RepairModel repairModel) { RepairModel repair = _context.Repairs.Find(repairModel.DocId); var dpt = _context.Departments.Find(repairModel.AccDpt); if (dpt == null) { ModelState.AddModelError("AccDpt", "查無部門代號!"); return(View(repair)); } if (repair != null) { repair.AccDpt = repairModel.AccDpt; repair.Ext = repairModel.Ext; repair.Mvpn = repairModel.Mvpn; repair.TroubleDes = repairModel.TroubleDes; repair.RepType = repairModel.RepType; _context.Entry(repair).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index", new { docId = repair.DocId })); } return(View(repair)); }
// อัพเดทเมื่อสถานะเป็น allow ให่้หักสต็อกเลย public ActionResult Approbation_popupUpdate(string approve, int reqID, int repID) { RequisitionModel reqModel = new RequisitionModel(); // ค้นเอา stock_id จากการเบิก Database db = new Database(); RequisitionDAO reqDAO = new RequisitionDAO(db); reqModel = new RequisitionModel(); reqModel = reqDAO.FindById(reqID); db.Close(); // แล้วเอามาค้นเอาข้อมูลสต๊อก db = new Database(); StockDAO sDAO = new StockDAO(db); StockModel sModel = sDAO.FindById(reqModel.STOCK_NO.STOCK_ID); db.Close(); RequisitionModel rqModel = new RequisitionModel(); rqModel.REQ_ID = reqID; rqModel.APROVE = approve; db = new Database(); reqDAO = new RequisitionDAO(db); int ap = reqDAO.Approbation(rqModel); db.Close(); if (approve.Equals("allow") && !reqModel.APROVE.Equals("allow")) { if (ap > 0) { // ของที่เบิก ต้องมีจำนวน น้อยกว่าเท่ากับของที่อยู่ในสต๊อก if (reqModel.REQ_UNIT <= sModel.UNIT) { int stkMinus = sModel.UNIT - reqModel.REQ_UNIT; // รับค่าที่ทำการหักสต๊อกแล้ว sModel = new StockModel(); sModel.STOCK_ID = reqModel.STOCK_NO.STOCK_ID; sModel.UNIT = stkMinus; System.Diagnostics.Debug.WriteLine("sModel.STOCK_ID :" + sModel.STOCK_ID); db = new Database(); sDAO = new StockDAO(db); sDAO.StockDeduction(sModel); db.Close(); } else { return(RedirectToAction("Alert", "Requisition", new { link = "../Requisition/approbationManagement", massage = "ไม่สามารถเบิกมากกว่าจำนวนของที่มีในคลังได้" })); } } } else if ((approve.Equals("wait") || approve.Equals("not")) && reqModel.APROVE.Equals("allow")) { int stkMinus = sModel.UNIT + reqModel.REQ_UNIT; // รับค่าที่ทำการหักสต๊อกแล้ว sModel = new StockModel(); sModel.STOCK_ID = reqModel.STOCK_NO.STOCK_ID; sModel.UNIT = stkMinus; db = new Database(); sDAO = new StockDAO(db); sDAO.StockDeduction(sModel); db.Close(); } RepairModel rModel = new RepairModel(); rModel.REPAIR_NO = repID; rModel.ALERT_STATUS = "1"; db = new Database(); RepairDAO rDAO = new RepairDAO(db); rDAO.AlertStatus(rModel); db.Close(); return(Redirect("~/Requisition/approbationManagement")); }
// PUT: api/Repairs/5 public void Put(int id, [FromBody] RepairModel value) { var service = new RepairsService(); service.AddOrEditRepair(value); }
// DELETE: api/Repair/5 public void Delete([FromBody] RepairModel value) { new RepairService().Remove(value); }
public async Task <IViewComponentResult> InvokeAsync(string id) { /* Get repair and flow details. */ RepairModel repair = _context.Repairs.Find(id); RepairFlowModel repairFlow = _context.RepairFlows.Where(f => f.DocId == id && f.Status == "?") .FirstOrDefault(); /* Insert values. */ AssignModel assign = new AssignModel(); assign.DocId = id; /* 根據當下流程的人員做額外的流程控管 */ List <SelectListItem> listItem = new List <SelectListItem>(); if (repairFlow != null) { assign.Cls = repairFlow.Cls; //if (repairFlow.Cls == "申請人") //統一回申請人結案 //{ /* 廢除選項在首頁 */ // listItem.Add(new SelectListItem { Text = "廢除", Value = "廢除" }); //} if (repairFlow.Cls == "驗收人" || repairFlow.Cls == "工務主管") //統一回申請人=驗收人結案 { listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } if (repairFlow.Cls == "工務/營建工程師") //工務/營建工程師自己為驗收人時 { if (repair.CheckerId == repairFlow.UserId) //驗收人為自己 { listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } } } /* 增設流程 */ if (repair.RepType == "增設") { listItem.Add(new SelectListItem { Text = "申請人", Value = "申請人" }); listItem.Add(new SelectListItem { Text = "驗收人", Value = "驗收人" }); listItem.Add(new SelectListItem { Text = "單位主管", Value = "單位主管" }); listItem.Add(new SelectListItem { Text = "單位主任", Value = "單位主任" }); listItem.Add(new SelectListItem { Text = "單位副院長", Value = "單位副院長" }); listItem.Add(new SelectListItem { Text = "工務/營建工程師", Value = "工務/營建工程師" }); listItem.Add(new SelectListItem { Text = "工務主管", Value = "工務主管" }); listItem.Add(new SelectListItem { Text = "工務主任", Value = "工務主任" }); listItem.Add(new SelectListItem { Text = "營建主管", Value = "營建主管" }); listItem.Add(new SelectListItem { Text = "營建主任", Value = "營建主任" }); } else //維修流程 { listItem.Add(new SelectListItem { Text = "申請人", Value = "申請人" }); listItem.Add(new SelectListItem { Text = "驗收人", Value = "驗收人" }); listItem.Add(new SelectListItem { Text = "單位主管", Value = "單位主管" }); listItem.Add(new SelectListItem { Text = "工務/營建工程師", Value = "工務/營建工程師" }); listItem.Add(new SelectListItem { Text = "工務主管", Value = "工務主管" }); listItem.Add(new SelectListItem { Text = "工務主任", Value = "工務主任" }); listItem.Add(new SelectListItem { Text = "營建主管", Value = "營建主管" }); listItem.Add(new SelectListItem { Text = "營建主任", Value = "營建主任" }); listItem.Add(new SelectListItem { Text = "工務經辦", Value = "工務經辦" }); } listItem.Add(new SelectListItem { Text = "列管財產負責人", Value = "列管財產負責人" }); listItem.Add(new SelectListItem { Text = "固資財產負責人", Value = "固資財產負責人" }); listItem.Add(new SelectListItem { Text = "其他", Value = "其他" }); ViewData["FlowCls"] = new SelectList(listItem, "Value", "Text", ""); List <SelectListItem> listItem3 = new List <SelectListItem>(); listItem3.Add(new SelectListItem { Text = "", Value = "" }); ViewData["FlowUid"] = new SelectList(listItem3, "Value", "Text", ""); assign.Hint = "單位請修→工務工程師→工務主管(若有費用)→單位驗收人→結案。"; ViewData["Hint2"] = "單位請修→單位主管(護理長)→單位主任→工務工程師 [若費用5000元以上:單位主管(護理長)→" + "單位直屬副院長→工務工程師] →工務主管→工務工程師→工務主管→單位驗收人→結案"; ViewData["Hint3"] = "單位請修→工務工程師→工務主管→工務主任→列管/固資財產負責人(有財產編號時)→單位驗收人→結案"; /* 於流程頁面顯示請修類型、及處理狀態*/ string hintRepType = repair.RepType; string hintRepState = ""; var repDtl = _context.RepairDtls.Where(dtl => dtl.DocId == id).FirstOrDefault(); if (repDtl != null) { hintRepState = _context.DealStatuses.Find(repDtl.DealState).Title; } ViewData["HintRepType"] = hintRepType + " / " + hintRepState; return(View(assign)); }
public ActionResult BillServicesAssign_Printing(string type, int repID) { LocalReport locRep = new LocalReport(); string path = Path.Combine(Server.MapPath("~/Reportor/"), "BillServicesAssign_Printing.rdlc"); System.Diagnostics.Debug.WriteLine("TEST PATH FILE :" + path); if (System.IO.File.Exists(path)) { locRep.ReportPath = path; } else { return(Redirect("~/Services")); } Database db = new Database(); RepairDAO repDAO = new RepairDAO(db); RepairModel repModel = repDAO.FindById(repID); db.Close(); ReportParameter[] pr = new ReportParameter[] { new ReportParameter("CDETAIL", repModel.CUSTOMER.C_NAME + " " + repModel.CUSTOMER.C_LASTNAME + (!repModel.CUSTOMER.C_TEL.Equals("")?" เบอร์โทร : " + repModel.CUSTOMER.C_TEL:" ") + (!repModel.CUSTOMER.C_ADDRESS.Equals("")?" ที่อยู่ : " + repModel.CUSTOMER.C_ADDRESS:" ")), new ReportParameter("STAFF", repModel.STAFF.NAME + " " + repModel.STAFF.LASTNAME), new ReportParameter("PRODUCT", repModel.PRODUCT.TYPE.PRO_TYPE_NAME + " " + repModel.PRODUCT.BANRD.PRO_BAND_NAME + " " + repModel.MODEL + " " + repModel.COLOR), new ReportParameter("DAMAGE", repModel.DAMAGE), new ReportParameter("ASSIGN_DATE", repModel.DATE_ASSIGN), new ReportParameter("CONSIGN_DATE", repModel.DATE_CONSIGN.ToString()), new ReportParameter("RECIPIENT", repModel.RECIPIENT_ID.NAME + " " + repModel.RECIPIENT_ID.LASTNAME), new ReportParameter("REPID", repModel.REPAIR_NO.ToString()) }; locRep.SetParameters(pr); locRep.GetDefaultPageSettings(); locRep.DisplayName = repModel.REPAIR_NO.ToString(); string reportType = type; string mimeType; string encoding; string fileNameExtension; string deviceInfoA4 = "<DeviceInfo>" + " <OutputFormat>" + type + "</OutputFormat>" + " <PageWidth>17.78cm</PageWidth>" + " <PageHeight>12.7cm</PageHeight>" + " <MarginTop>1cm</MarginTop>" + " <MarginLeft>0.5in</MarginLeft>" + " <MarginRight>0.5in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; renderedBytes = locRep.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(File(renderedBytes, mimeType)); }
public ActionResult NextFlow(AssignModel assign) { var ur = _userRepo.Find(u => u.UserName == this.User.Identity.Name).FirstOrDefault(); /* 工程師的流程控管 */ if (assign.Cls == "工務/營建工程師") { /* 如點選有費用、卻無輸入費用明細 */ var isCharged = _context.RepairDtls.Where(d => d.DocId == assign.DocId).FirstOrDefault().IsCharged; if (isCharged == "Y") { var CheckRepairCost = _context.RepairCosts.Where(c => c.DocId == assign.DocId).FirstOrDefault(); if (CheckRepairCost == null) { string msg = "尚未輸入費用明細!!"; return(BadRequest(msg)); } } var repairDtl = _context.RepairDtls.Where(d => d.DocId == assign.DocId).FirstOrDefault(); /* 3 = 已完成,4 = 報廢 */ if (repairDtl.DealState == 3 || repairDtl.DealState == 4) { if (repairDtl.EndDate == null) { string msg = "報廢及已完成,需輸入完工日!!"; return(BadRequest(msg)); } } /* 工程師做結案 */ if (assign.FlowCls == "結案") { if (_context.RepairEmps.Where(emp => emp.DocId == assign.DocId).Count() <= 0) { string msg = "沒有維修工程師紀錄!!"; return(BadRequest(msg)); } else if (_context.RepairDtls.Find(assign.DocId).EndDate == null) { string msg = "沒有完工日!!"; return(BadRequest(msg)); } else if (_context.RepairDtls.Find(assign.DocId).DealState == 0) { string msg = "處理狀態不可空值!!"; return(BadRequest(msg)); } if (_context.RepairDtls.Find(assign.DocId).FailFactor == 0) { string msg = "故障原因不可空白!!"; return(BadRequest(msg)); } if (string.IsNullOrEmpty(_context.RepairDtls.Find(assign.DocId).InOut)) { string msg = "維修方式不可空白!!"; return(BadRequest(msg)); } if (_context.RepairDtls.Find(assign.DocId).DealState == 1 || _context.RepairDtls.Find(assign.DocId).DealState == 2) { string msg = "處理狀態不可為處理中或未處理!!"; return(BadRequest(msg)); } } } if (assign.FlowCls == "結案" || assign.FlowCls == "廢除") { assign.FlowUid = ur.Id; } if (ModelState.IsValid) { RepairFlowModel rf = _context.RepairFlows.Where(f => f.DocId == assign.DocId && f.Status == "?").FirstOrDefault(); if (assign.FlowCls == "驗收人") { if (_context.RepairEmps.Where(emp => emp.DocId == assign.DocId).Count() <= 0) { //throw new Exception("沒有維修工程師紀錄!!"); string msg = "沒有維修工程師紀錄!!"; return(BadRequest(msg)); } else if (_context.RepairDtls.Find(assign.DocId).EndDate == null) { //throw new Exception("沒有完工日!!"); string msg = "沒有完工日!!"; return(BadRequest(msg)); } else if (_context.RepairDtls.Find(assign.DocId).DealState == 0) { //throw new Exception("處理狀態不可空值!!"); string msg = "處理狀態不可空值!!"; return(BadRequest(msg)); } if (_context.RepairDtls.Find(assign.DocId).FailFactor == 0) { //throw new Exception("故障原因不可空白!!"); string msg = "故障原因不可空白!!"; return(BadRequest(msg)); } if (string.IsNullOrEmpty(_context.RepairDtls.Find(assign.DocId).InOut)) { //throw new Exception("維修方式不可空白!!"); string msg = "維修方式不可空白!!"; return(BadRequest(msg)); } if (_context.RepairDtls.Find(assign.DocId).DealState == 1 || _context.RepairDtls.Find(assign.DocId).DealState == 2) { //throw new Exception("維修方式不可空白!!"); string msg = "處理狀態不可為處理中或未處理!!"; return(BadRequest(msg)); } } if (assign.FlowCls == "結案") { RepairDtlModel rd = _context.RepairDtls.Find(assign.DocId); rd.CloseDate = DateTime.Now; rf.Opinions = "[" + assign.AssignCls + "]" + Environment.NewLine + assign.AssignOpn; rf.Status = "2"; rf.UserId = ur.Id; rf.UserName = _context.AppUsers.Find(ur.Id).FullName; rf.Rtt = DateTime.Now; rf.Rtp = ur.Id; _context.Entry(rf).State = EntityState.Modified; _context.Entry(rd).State = EntityState.Modified; //If "結案", delete 1 dealing doc to the engineer. //var repairDoc = _context.Repairs.Find(assign.DocId); //var eng = _context.EngDealingDocs.Find(repairDoc.EngId); //eng.DealingDocs = eng.DealingDocs - 1; //_context.Entry(eng).State = EntityState.Modified; _context.SaveChanges(); //Send Mail //To all users in this repair's flow. //try //{ // Tmail mail = new Tmail(); // string body = ""; // string sto = ""; // AppUserModel u; // RepairModel repair = _context.Repairs.Find(assign.DocId); // if (repair.Building != null) // { // repair.BuildingName = _context.Buildings.Where(b => b.BuildingId == Convert.ToInt32(repair.Building)).FirstOrDefault().BuildingName; // repair.FloorName = _context.Floors.Where(f => f.BuildingId == Convert.ToInt32(repair.Building) && f.FloorId == repair.Floor).FirstOrDefault().FloorName; // repair.AreaName = _context.Places.Where(p => p.BuildingId == Convert.ToInt32(repair.Building) && p.FloorId == repair.Floor && p.PlaceId == repair.Area).FirstOrDefault().PlaceName; // } // else // { // repair.BuildingName = "(無資料)"; // repair.FloorName = ""; // repair.AreaName = ""; // } // mail.from = new System.Net.Mail.MailAddress(ur.Email); //u.Email // /* If is charged, send mail to all flow users. */ // if (rd.IsCharged == "Y") // { // _context.RepairFlows.Where(f => f.DocId == assign.DocId) // .ToList() // .ForEach(f => // { // u = _context.AppUsers.Find(f.UserId); // sto += u.Email + ","; // }); // } // else // { // _context.RepairFlows.Where(f => f.DocId == assign.DocId).Where(f => f.Cls.Contains("工程師") == false) // .ToList() // .ForEach(f => // { // u = _context.AppUsers.Find(f.UserId); // sto += u.Email + ","; // }); // } // var temp = _context.RepairFlows.Where(f => f.DocId == assign.DocId).Where(f => f.Cls.Contains("工程師") == false) // .ToList(); // mail.sto = sto.TrimEnd(new char[] { ',' }); // mail.message.Subject = "工務智能請修系統[請修案-結案通知]:設備名稱: " + repair.AssetName; // body += "<p>表單編號:" + repair.DocId + "</p>"; // body += "<p>申請日期:" + repair.ApplyDate.ToString("yyyy/MM/dd") + "</p>"; // body += "<p>申請人:" + repair.UserName + "</p>"; // body += "<p>財產編號:" + repair.AssetNo + "</p>"; // body += "<p>設備名稱:" + repair.AssetName + "</p>"; // body += "<p>請修地點:" + repair.PlaceLoc + " " + repair.BuildingName + " " + repair.FloorName + " " + repair.AreaName + "</p>"; // //body += "<p>放置地點:" + repair.PlaceLoc + "</p>"; // body += "<p>故障描述:" + repair.TroubleDes + "</p>"; // body += "<p>處理描述:" + rd.DealDes + "</p>"; // body += "<p><a href='http://dms.cch.org.tw/EDIS/Account/Login" + "?DocId=" + repair.DocId + "&dealType=Views'" + ">檢視案件</a></p>"; // body += "<br/>"; // body += "<p>使用IE瀏覽器注意事項:</p>"; // body += "<p>「工具」→「相容性檢視設定」→移除cch.org.tw</p>"; // body += "<br/>"; // body += "<h3>此封信件為系統通知郵件,請勿回覆。</h3>"; // body += "<br/>"; // body += "<h3 style='color:red'>如有任何疑問請聯絡工務部,分機3033或7033。<h3>"; // mail.message.Body = body; // mail.message.IsBodyHtml = true; // mail.SendMail(); //} //catch (Exception ex) //{ // throw new Exception(ex.Message); //} } else if (assign.FlowCls == "廢除") { rf.Opinions = "[廢除]" + Environment.NewLine + assign.AssignOpn; rf.Status = "3"; rf.Rtt = DateTime.Now; rf.Rtp = ur.Id; _context.Entry(rf).State = EntityState.Modified; _context.SaveChanges(); } else { //轉送下一關卡 rf.Opinions = "[" + assign.AssignCls + "]" + Environment.NewLine + assign.AssignOpn; rf.Status = "1"; rf.Rtt = DateTime.Now; rf.Rtp = ur.Id; _context.Entry(rf).State = EntityState.Modified; _context.SaveChanges(); // RepairFlowModel flow = new RepairFlowModel(); flow.DocId = assign.DocId; flow.StepId = rf.StepId + 1; flow.UserId = assign.FlowUid.Value; flow.UserName = _context.AppUsers.Find(assign.FlowUid.Value).FullName; flow.Status = "?"; flow.Cls = assign.FlowCls; flow.Rtt = DateTime.Now; _context.RepairFlows.Add(flow); _context.SaveChanges(); //Send Mail //To the next flow user. try { Tmail mail = new Tmail(); string body = ""; AppUserModel u; RepairModel repair = _context.Repairs.Find(assign.DocId); if (repair.Building != null) { repair.BuildingName = _context.Buildings.Where(b => b.BuildingId == Convert.ToInt32(repair.Building)).FirstOrDefault().BuildingName; repair.FloorName = _context.Floors.Where(f => f.BuildingId == Convert.ToInt32(repair.Building) && f.FloorId == repair.Floor).FirstOrDefault().FloorName; repair.AreaName = _context.Places.Where(p => p.BuildingId == Convert.ToInt32(repair.Building) && p.FloorId == repair.Floor && p.PlaceId == repair.Area).FirstOrDefault().PlaceName; } else { repair.BuildingName = "(無資料)"; repair.FloorName = ""; repair.AreaName = ""; } mail.from = new System.Net.Mail.MailAddress(ur.Email); //ur.Email u = _context.AppUsers.Find(flow.UserId); mail.to = new System.Net.Mail.MailAddress(u.Email); //u.Email //mail.cc = new System.Net.Mail.MailAddress("*****@*****.**"); mail.message.Subject = "工務智能請修系統[請修案]:設備名稱: " + repair.AssetName; body += "<p>表單編號:" + repair.DocId + "</p>"; body += "<p>申請日期:" + repair.ApplyDate.ToString("yyyy/MM/dd") + "</p>"; body += "<p>申請人:" + repair.UserName + "</p>"; body += "<p>財產編號:" + repair.AssetNo + "</p>"; body += "<p>設備名稱:" + repair.AssetName + "</p>"; body += "<p>故障描述:" + repair.TroubleDes + "</p>"; body += "<p>請修地點:" + repair.PlaceLoc + " " + repair.BuildingName + " " + repair.FloorName + " " + repair.AreaName + "</p>"; //body += "<p>放置地點:" + repair.PlaceLoc + "</p>"; body += "<p><a href='http://dms.cch.org.tw/EDIS/Account/Login" + "?docId=" + repair.DocId + "&dealType=Edit'" + ">處理案件</a></p>"; body += "<br/>"; body += "<p>使用IE瀏覽器注意事項:</p>"; body += "<p>「工具」→「相容性檢視設定」→移除cch.org.tw</p>"; body += "<br/>"; body += "<h3>此封信件為系統通知郵件,請勿回覆。</h3>"; body += "<br/>"; body += "<h3 style='color:red'>如有任何疑問請聯絡工務部,分機3033或7033。<h3>"; mail.message.Body = body; mail.message.IsBodyHtml = true; /* If next flow is not engineer, send mail. */ if (flow.Cls.Contains("工程師") == false) { mail.SendMail(); } } catch (Exception ex) { throw new Exception(ex.Message); } } return(new JsonResult(assign) { Value = new { success = true, error = "" } }); } else { string msg = ""; foreach (var error in ViewData.ModelState.Values.SelectMany(modelState => modelState.Errors)) { msg += error.ErrorMessage + Environment.NewLine; } throw new Exception(msg); } }
public async Task <IViewComponentResult> InvokeAsync(string id) { /* Get repair and flow details. */ RepairModel repair = _context.BMEDRepairs.Find(id); RepairDtlModel repairDtl = _context.BMEDRepairDtls.Find(id); RepairFlowModel repairFlow = _context.BMEDRepairFlows.Where(f => f.DocId == id && f.Status == "?") .FirstOrDefault(); /* 增設流程 */ List <SelectListItem> listItem = new List <SelectListItem>(); if (repair.RepType == "增設") { listItem.Add(new SelectListItem { Text = "申請人", Value = "申請人" }); listItem.Add(new SelectListItem { Text = "驗收人", Value = "驗收人" }); listItem.Add(new SelectListItem { Text = "單位主管", Value = "單位主管" }); listItem.Add(new SelectListItem { Text = "單位主任", Value = "單位主任" }); listItem.Add(new SelectListItem { Text = "單位副院長", Value = "單位副院長" }); listItem.Add(new SelectListItem { Text = "維修工程師", Value = "維修工程師" }); listItem.Add(new SelectListItem { Text = "設備工程師", Value = "設備工程師" }); listItem.Add(new SelectListItem { Text = "醫工主管", Value = "醫工主管" }); listItem.Add(new SelectListItem { Text = "賀康主管", Value = "賀康主管" }); //listItem.Add(new SelectListItem { Text = "醫工主任", Value = "醫工主任" }); } else //維修流程 { listItem.Add(new SelectListItem { Text = "申請人", Value = "申請人" }); listItem.Add(new SelectListItem { Text = "驗收人", Value = "驗收人" }); listItem.Add(new SelectListItem { Text = "單位主管", Value = "單位主管" }); listItem.Add(new SelectListItem { Text = "維修工程師", Value = "維修工程師" }); listItem.Add(new SelectListItem { Text = "設備工程師", Value = "設備工程師" }); listItem.Add(new SelectListItem { Text = "醫工主管", Value = "醫工主管" }); listItem.Add(new SelectListItem { Text = "賀康主管", Value = "賀康主管" }); //額外流程控管 if (repairDtl.IsCharged == "Y" && repairDtl.NotInExceptDevice == "N") //有費用 & 非統包 { var itemToRemove = listItem.Single(r => r.Value == "驗收人"); listItem.Remove(itemToRemove); //只醫工、賀康主管可結案 } if (repairDtl.DealState == 4) //報廢 { var itemToRemove = listItem.Single(r => r.Value == "驗收人"); listItem.Remove(itemToRemove); //只醫工、賀康主管可結案 } if (repairDtl.IsCharged == "Y" && repairDtl.NotInExceptDevice == "Y") //有費用 & 統包 { var itemToRemove = listItem.Single(r => r.Value == "醫工主管"); listItem.Remove(itemToRemove); //移除醫工主管的選項 } if (repairFlow.Cls == "驗收人" && repairDtl.IsCharged == "Y") //有費用 & 關卡於驗收人,下一關只可給工程師 { var itemToRemove = listItem.SingleOrDefault(r => r.Value == "醫工主管"); if (itemToRemove != null) { listItem.Remove(itemToRemove); } itemToRemove = listItem.SingleOrDefault(r => r.Value == "賀康主管"); if (itemToRemove != null) { listItem.Remove(itemToRemove); } } // } //listItem.Add(new SelectListItem { Text = "列管財產負責人", Value = "列管財產負責人" }); //listItem.Add(new SelectListItem { Text = "固資財產負責人", Value = "固資財產負責人" }); listItem.Add(new SelectListItem { Text = "其他", Value = "其他" }); /* Insert values. */ AssignModel assign = new AssignModel(); assign.DocId = id; /* 根據當下流程的人員做額外的流程控管 */ if (repairFlow != null) { assign.Cls = repairFlow.Cls; if (repairFlow.Cls == "驗收人" || repairFlow.Cls == "醫工主管" || repairFlow.Cls == "賀康主管") //可結案人員 { listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } if (repairFlow.Cls == "驗收人" && repairDtl.IsCharged == "Y") //有費用 & 關卡於驗收人,下一關只可給工程師 { var itemToRemove = listItem.SingleOrDefault(r => r.Value == "結案"); if (itemToRemove != null) { listItem.Remove(itemToRemove); } } } ViewData["FlowCls"] = new SelectList(listItem, "Value", "Text", ""); List <SelectListItem> listItem3 = new List <SelectListItem>(); listItem3.Add(new SelectListItem { Text = "", Value = "" }); ViewData["FlowUid"] = new SelectList(listItem3, "Value", "Text", ""); /* Get Default Checker for MedEngineers to edit. */ List <SelectListItem> listItem4 = new List <SelectListItem>(); var defaultChecker = _context.AppUsers.Find(repair.CheckerId); listItem4.Add(new SelectListItem { Text = defaultChecker.FullName, Value = defaultChecker.Id.ToString() }); ViewData["DefaultChecker"] = new SelectList(listItem4, "Value", "Text", defaultChecker.Id.ToString()); /* 驗收人員所屬部門搜尋的下拉選單資料 */ var dptList = new[] { "K", "P", "C" }; //本院部門 var departments = _context.Departments.Where(d => dptList.Contains(d.Loc)).ToList(); List <SelectListItem> listItem5 = new List <SelectListItem>(); foreach (var item in departments) { listItem5.Add(new SelectListItem { Text = item.Name_C + "(" + item.DptId + ")", //show DptName(DptId) Value = item.DptId }); } ViewData["BMEDQRYDPT"] = new SelectList(listItem5, "Value", "Text"); //assign.Hint = "申請者→負責工程師→使用單位→[(若有費用及報廢)醫工部主管、賀康主管]→結案"; assign.Hint = "申請者→負責工程師→使用單位→(若有費用)負責工程師→[醫工部主管、賀康主管]→結案"; /* 於流程頁面顯示請修類型、及處理狀態*/ string hintRepType = repair.RepType; string hintRepState = ""; var repDtl = _context.BMEDRepairDtls.Where(dtl => dtl.DocId == id).FirstOrDefault(); if (repDtl != null) { hintRepState = _context.BMEDDealStatuses.Find(repDtl.DealState).Title; } ViewData["HintRepType"] = hintRepType + " / " + hintRepState; return(View(assign)); }
public async Task <IActionResult> NextFlow(AssignModel assign) { var ur = _userRepo.Find(u => u.UserName == this.User.Identity.Name).FirstOrDefault(); var repairDtl = _context.BMEDRepairDtls.Find(assign.DocId); /* 工程師的流程控管 */ if (assign.Cls == "設備工程師") { /* 如點選有費用、卻無輸入費用明細 */ var isCharged = _context.BMEDRepairDtls.Where(d => d.DocId == assign.DocId).FirstOrDefault().IsCharged; if (isCharged == "Y") { var CheckRepairCost = _context.BMEDRepairCosts.Where(c => c.DocId == assign.DocId).FirstOrDefault(); if (CheckRepairCost == null) { throw new Exception("尚未輸入費用明細!!"); } } } // var repairDtl = _context.BMEDRepairDtls.Where(d => d.DocId == assign.DocId).FirstOrDefault(); // /* 3 = 已完成,4 = 報廢 */ // if (repairDtl.DealState == 3 || repairDtl.DealState == 4) // { // if(repairDtl.EndDate == null) // { // throw new Exception("報廢及已完成,需輸入完工日!!"); // } // } if (assign.FlowCls == "結案" || assign.FlowCls == "廢除") { assign.FlowUid = ur.Id; } if (ModelState.IsValid) { RepairFlowModel rf = _context.BMEDRepairFlows.Where(f => f.DocId == assign.DocId && f.Status == "?").FirstOrDefault(); if (assign.FlowCls == "驗收人") { if (_context.BMEDRepairEmps.Where(emp => emp.DocId == assign.DocId).Count() <= 0) { throw new Exception("沒有維修工程師紀錄!!"); } else if (_context.BMEDRepairDtls.Find(assign.DocId).EndDate == null) { throw new Exception("沒有完工日!!"); } else if (_context.BMEDRepairDtls.Find(assign.DocId).DealState == 0) { throw new Exception("處理狀態不可空值!!"); } if (_context.BMEDRepairDtls.Find(assign.DocId).FailFactor == 0) { throw new Exception("故障原因不可空白!!"); } if (string.IsNullOrEmpty(_context.BMEDRepairDtls.Find(assign.DocId).InOut)) { throw new Exception("維修方式不可空白!!"); } if (_context.BMEDRepairDtls.Find(assign.DocId).DealState == 3 || _context.BMEDRepairDtls.Find(assign.DocId).DealState == 4 || _context.BMEDRepairDtls.Find(assign.DocId).DealState == 8) { //Do nothing. //狀態為【已完成】、【報廢】、【退件】才可送至驗收人 } else { throw new Exception("送至驗收人處理狀態只可為【已完成】、【報廢】、【退件】!!"); } } if (assign.FlowCls == "結案") { if (assign.Cls == "驗收人" && repairDtl != null) { if (repairDtl.IsCharged == "Y") { throw new Exception("有費用之案件不可由驗收人直接結案!"); } } RepairDtlModel rd = _context.BMEDRepairDtls.Find(assign.DocId); rd.CloseDate = DateTime.Now; rf.Opinions = "[" + assign.AssignCls + "]" + Environment.NewLine + assign.AssignOpn; rf.Status = "2"; rf.UserId = ur.Id; rf.UserName = _context.AppUsers.Find(ur.Id).FullName; rf.Rtt = DateTime.Now; rf.Rtp = ur.Id; _context.Entry(rf).State = EntityState.Modified; _context.Entry(rd).State = EntityState.Modified; _context.SaveChanges(); // Save stock to ERP system. var ERPreponse = await SaveToERPAsync(assign.DocId); //Send Mail //To all users in this repair's flow. Tmail mail = new Tmail(); string body = ""; string sto = ""; AppUserModel u; RepairModel repair = _context.BMEDRepairs.Find(assign.DocId); mail.from = new System.Net.Mail.MailAddress(ur.Email); //u.Email _context.BMEDRepairFlows.Where(f => f.DocId == assign.DocId) .ToList() .ForEach(f => { u = _context.AppUsers.Find(f.UserId); sto += u.Email + ","; }); mail.sto = sto.TrimEnd(new char[] { ',' }); mail.message.Subject = "醫工工務智能保修系統[醫工請修案-結案通知]:設備名稱: " + repair.AssetName; body += "<p>表單編號:" + repair.DocId + "</p>"; body += "<p>申請日期:" + repair.ApplyDate.ToString("yyyy/MM/dd") + "</p>"; body += "<p>申請人:" + repair.UserName + "</p>"; body += "<p>財產編號:" + repair.AssetNo + "</p>"; body += "<p>設備名稱:" + repair.AssetName + "</p>"; //body += "<p>請修地點:" + repair.PlaceLoc + " " + repair.BuildingName + " " + repair.FloorName + " " + repair.AreaName + "</p>"; body += "<p>放置地點:" + repair.PlaceLoc + "</p>"; body += "<p>故障描述:" + repair.TroubleDes + "</p>"; body += "<p>處理描述:" + rd.DealDes + "</p>"; body += "<p><a href='http://dms.cch.org.tw/EDIS/Account/Login'" + "?DocId=" + repair.DocId + "&dealType=BMEDRepViews" + ">檢視案件</a></p>"; body += "<br/>"; body += "<h3>此封信件為系統通知郵件,請勿回覆。</h3>"; body += "<br/>"; //body += "<h3 style='color:red'>如有任何疑問請聯絡工務部,分機3033或7033。<h3>"; mail.message.Body = body; mail.message.IsBodyHtml = true; mail.SendMail(); } else if (assign.FlowCls == "廢除") { rf.Opinions = "[廢除]" + Environment.NewLine + assign.AssignOpn; rf.Status = "3"; rf.Rtt = DateTime.Now; rf.Rtp = ur.Id; _context.Entry(rf).State = EntityState.Modified; _context.SaveChanges(); } else { //轉送下一關卡 rf.Opinions = "[" + assign.AssignCls + "]" + Environment.NewLine + assign.AssignOpn; rf.Status = "1"; rf.Rtt = DateTime.Now; rf.Rtp = ur.Id; _context.Entry(rf).State = EntityState.Modified; _context.SaveChanges(); // RepairFlowModel flow = new RepairFlowModel(); flow.DocId = assign.DocId; flow.StepId = rf.StepId + 1; flow.UserId = assign.FlowUid.Value; flow.UserName = _context.AppUsers.Find(assign.FlowUid.Value).FullName; flow.Status = "?"; flow.Cls = assign.FlowCls; flow.Rtt = DateTime.Now; _context.BMEDRepairFlows.Add(flow); _context.SaveChanges(); //Send Mail //To user and the next flow user. Tmail mail = new Tmail(); string body = ""; AppUserModel u; RepairModel repair = _context.BMEDRepairs.Find(assign.DocId); mail.from = new System.Net.Mail.MailAddress(ur.Email); //ur.Email u = _context.AppUsers.Find(flow.UserId); mail.to = new System.Net.Mail.MailAddress(u.Email); //u.Email //mail.cc = new System.Net.Mail.MailAddress("*****@*****.**"); mail.message.Subject = "醫工工務智能保修系統[醫工請修案]:設備名稱: " + repair.AssetName; body += "<p>表單編號:" + repair.DocId + "</p>"; body += "<p>申請日期:" + repair.ApplyDate.ToString("yyyy/MM/dd") + "</p>"; body += "<p>申請人:" + repair.UserName + "</p>"; body += "<p>財產編號:" + repair.AssetNo + "</p>"; body += "<p>設備名稱:" + repair.AssetName + "</p>"; body += "<p>故障描述:" + repair.TroubleDes + "</p>"; //body += "<p>請修地點:" + repair.PlaceLoc + " " + repair.BuildingName + " " + repair.FloorName + " " + repair.AreaName + "</p>"; body += "<p>放置地點:" + repair.PlaceLoc + "</p>"; body += "<p><a href='http://dms.cch.org.tw/EDIS/Account/Login'" + "?docId=" + repair.DocId + "&dealType=BMEDRepEdit" + ">處理案件</a></p>"; body += "<br/>"; body += "<h3>此封信件為系統通知郵件,請勿回覆。</h3>"; body += "<br/>"; //body += "<h3 style='color:red'>如有任何疑問請聯絡工務部,分機3033或7033。<h3>"; mail.message.Body = body; mail.message.IsBodyHtml = true; mail.SendMail(); } return(new JsonResult(assign) { Value = new { success = true, error = "" } }); } else { string msg = ""; foreach (var error in ViewData.ModelState.Values.SelectMany(modelState => modelState.Errors)) { msg += error.ErrorMessage + Environment.NewLine; } throw new Exception(msg); } }
public IActionResult GetNextEmp(string cls, string docid /*, string vendor*/) { List <SelectListItem> list = new List <SelectListItem>(); List <string> s; SelectListItem li; AppUserModel u; RepairModel r = _context.BMEDRepairs.Find(docid); AssetModel asset = _context.BMEDAssets.Where(a => a.AssetNo == r.AssetNo).FirstOrDefault(); switch (cls) { case "維修工程師": roleManager.GetUsersInRole("Engineer").ToList() .ForEach(x => { u = _context.AppUsers.Where(ur => ur.UserName == x).FirstOrDefault(); if (u != null) { li = new SelectListItem(); li.Text = u.FullName; li.Value = u.Id.ToString(); list.Add(li); } }); break; case "醫工主管": s = roleManager.GetUsersInRole("MedMgr").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "賀康主管": //設備主管 s = roleManager.GetUsersInRole("MedAssetMgr").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "醫工主任": s = roleManager.GetUsersInRole("MedDirector").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "醫工經辦": list = new List <SelectListItem>(); u = _context.AppUsers.Where(ur => ur.UserName == "1814").FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName; li.Value = u.Id.ToString(); list.Add(li); } break; case "單位主管": case "單位主任": //s = roleManager.GetUsersInRole("Manager").ToList(); /* 擷取申請人單位底下所有人員 */ //string c = _context.AppUsers.Find(r.UserId).DptId; //var dptUsers = _context.AppUsers.Where(a => a.DptId == c).ToList(); //list = new List<SelectListItem>(); //foreach (var item in dptUsers) //{ // li = new SelectListItem(); // li.Text = item.FullName; // li.Value = item.Id.ToString(); // list.Add(li); //} break; case "單位副院長": s = roleManager.GetUsersInRole("ViceSI").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "申請人": if (r != null) { list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = r.UserName; li.Value = r.UserId.ToString(); list.Add(li); } else { list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = "宋大衛"; li.Value = "000"; list.Add(li); } break; case "驗收人": if (_context.BMEDRepairEmps.Where(emp => emp.DocId == docid).Count() <= 0) { throw new Exception("沒有維修工程師紀錄!!"); } else if (_context.BMEDRepairDtls.Find(docid).EndDate == null) { throw new Exception("沒有完工日!!"); } if (r != null) { /* 與驗收人同單位的成員(包括驗收人) */ var checkerDptId = _context.AppUsers.Find(r.CheckerId).DptId; List <AppUserModel> ul = _context.AppUsers.Where(f => f.DptId == checkerDptId) .Where(f => f.Status == "Y").ToList(); if (asset != null) { if (asset.DelivDpt != r.DptId) { ul.AddRange(_context.AppUsers.Where(f => f.DptId == asset.DelivDpt) .Where(f => f.Status == "Y").ToList()); } } /* 驗收人 */ var checker = _context.AppUsers.Find(r.CheckerId); list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = checker.FullName + "(" + checker.UserName + ")"; li.Value = checker.Id.ToString(); list.Add(li); foreach (AppUserModel l in ul) { /* 申請人以外的成員 */ if (l.Id != r.UserId) { li = new SelectListItem(); li.Text = l.FullName + "(" + l.UserName + ")"; li.Value = l.Id.ToString(); list.Add(li); } } } break; case "設備工程師": /* Get all engineers. */ s = roleManager.GetUsersInRole("MedEngineer").ToList(); var repEngId = _context.AppUsers.Find(r.EngId).UserName; list = new List <SelectListItem>(); /* 負責工程師 */ var engTemp = _context.AppUsers.Find(r.EngId); li = new SelectListItem(); li.Text = engTemp.FullName + "(" + engTemp.UserName + ")"; li.Value = engTemp.Id.ToString(); list.Add(li); /* 其他工程師 */ foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (u != null && l != repEngId) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "列管財產負責人": list = new List <SelectListItem>(); u = _context.AppUsers.Where(ur => ur.UserName == "181151").FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } break; case "固資財產負責人": list = new List <SelectListItem>(); u = _context.AppUsers.Where(ur => ur.UserName == "1814").FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } break; default: list = new List <SelectListItem>(); break; } return(Json(list)); }
public ActionResult GetNextEmp(string cls, string docid /*, string vendor*/) { List <SelectListItem> list = new List <SelectListItem>(); List <string> s; SelectListItem li; AppUserModel u; RepairModel r = _context.Repairs.Find(docid); AssetModel asset = _context.Assets.Where(a => a.AssetNo == r.AssetNo).FirstOrDefault(); switch (cls) { //case "維修工程師": // roleManager.GetUsersInRole("Engineer").ToList() // .ForEach(x => // { // u = _context.AppUsers.Where(ur => ur.UserName == x).FirstOrDefault(); // if (vendor != null && u != null) // { // if (u.VendorId != null) // { // if (u.VendorId.ToString() == vendor) // { // li = new SelectListItem(); // li.Text = u.FullName; // li.Value = u.Id.ToString(); // list.Add(li); // } // } // } // else // { // if (u != null) // { // li = new SelectListItem(); // li.Text = u.FullName; // li.Value = u.Id.ToString(); // list.Add(li); // } // } // }); // break; case "工務主管": s = roleManager.GetUsersInRole("RepMgr").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "工務主任": s = roleManager.GetUsersInRole("RepDirector").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "工務經辦": list = new List <SelectListItem>(); u = _context.AppUsers.Where(ur => ur.UserName == "1814").FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } break; case "營建主管": s = roleManager.GetUsersInRole("CaPMgr").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "營建主任": s = roleManager.GetUsersInRole("CaPDirector").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "單位主管": case "單位主任": //s = roleManager.GetUsersInRole("Manager").ToList(); /* 擷取申請人單位底下所有人員 */ //string c = _context.AppUsers.Find(r.UserId).DptId; //var dptUsers = _context.AppUsers.Where(a => a.DptId == c).ToList(); //list = new List<SelectListItem>(); //foreach (var item in dptUsers) //{ // li = new SelectListItem(); // li.Text = item.FullName; // li.Value = item.Id.ToString(); // list.Add(li); //} break; case "單位副院長": s = roleManager.GetUsersInRole("ViceSI").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "申請人": if (r != null) { list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = r.UserName; li.Value = r.UserId.ToString(); list.Add(li); } else { list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = "宋大衛"; li.Value = "000"; list.Add(li); } break; case "驗收人": if (_context.RepairEmps.Where(emp => emp.DocId == docid).Count() <= 0) { throw new Exception("沒有維修工程師紀錄!!"); } if (r != null) { /* 與驗收人同單位的成員(包括驗收人) */ var checkerDptId = _context.AppUsers.Find(r.CheckerId).DptId; List <AppUserModel> ul = _context.AppUsers.Where(f => f.DptId == checkerDptId) .Where(f => f.Status == "Y").ToList(); if (asset != null) { if (asset.DelivDpt != r.DptId) { ul.AddRange(_context.AppUsers.Where(f => f.DptId == asset.DelivDpt) .Where(f => f.Status == "Y").ToList()); } } /* 驗收人 */ var checker = _context.AppUsers.Find(r.CheckerId); list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = checker.FullName + "(" + checker.UserName + ")"; li.Value = checker.Id.ToString(); list.Add(li); foreach (AppUserModel l in ul) { /* 申請人以外的成員 */ if (l.Id != r.UserId) { li = new SelectListItem(); li.Text = l.FullName + "(" + l.UserName + ")"; li.Value = l.Id.ToString(); list.Add(li); } } } break; case "工務/營建工程師": /* Get all engineers. */ s = roleManager.GetUsersInRole("RepEngineer").ToList(); /* Get default engineer. */ var repEngId = _context.AppUsers.Find(r.EngId).UserName; var engTemp = _context.AppUsers.Find(r.EngId); var lastFlowEng = _context.RepairFlows.Where(rf => rf.DocId == docid) .Where(rf => rf.Cls.Contains("工程師")) .OrderByDescending(rf => rf.StepId).FirstOrDefault(); if (lastFlowEng != null) { repEngId = _context.AppUsers.Find(lastFlowEng.UserId).UserName; engTemp = _context.AppUsers.Find(lastFlowEng.UserId); } list = new List <SelectListItem>(); /* 負責工程師 */ li = new SelectListItem(); li.Text = engTemp.FullName + "(" + engTemp.UserName + ")"; li.Value = engTemp.Id.ToString(); list.Add(li); /* 其他工程師 */ foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (u != null && l != repEngId) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } } break; case "列管財產負責人": list = new List <SelectListItem>(); //u = _context.AppUsers.Where(ur => ur.UserName == "181151").FirstOrDefault(); u = _context.AppUsers.Where(ur => ur.UserName == "53929").FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } break; case "固資財產負責人": list = new List <SelectListItem>(); u = _context.AppUsers.Where(ur => ur.UserName == "1814").FirstOrDefault(); if (!string.IsNullOrEmpty(u.DptId)) { li = new SelectListItem(); li.Text = u.FullName + "(" + u.UserName + ")"; li.Value = u.Id.ToString(); list.Add(li); } break; default: list = new List <SelectListItem>(); break; } return(Json(list)); }
public ActionResult RepairDescriptionBilling(int repID) { string t = "pdf"; LocalReport lr = new LocalReport(); string path = Server.MapPath("~/Reportor/ExportBill.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } Database db = new Database(); RequisitionDAO rqDAO = new RequisitionDAO(db); List <RequisitionModel> reqModel = rqDAO.FindByRepairID(repID).Where(r => r.APROVE.Contains("allow")).ToList(); //HashSet<RequisitionModel> reqModel = rqDAO.FindByRepairID(repID).Where(r => r.APROVE.Contains("allow")).ToList(); db.Close(); var data = reqModel.Select(r => new { REQ_DATE = r.REQ_DATE.ToString("dd MMMM yyyy H:mm"), REQ_DETAIL = r.STOCK_NO.PART.TYPE.PART_TYPE_NAME + " " + r.STOCK_NO.PART.BRAND.PART_BRAND_NAME + " " + r.STOCK_NO.STOCK_INFO, REQ_UNIT = r.REQ_UNIT, REQ_PRICE = r.STOCK_NO.PRICE }).ToList(); db = new Database(); RepairDAO rDAO = new RepairDAO(db); RepairModel rModel = rDAO.FindById(repID); db.Close(); ReportParameter[] pr = new ReportParameter[] { new ReportParameter("NAME", rModel.CUSTOMER.C_NAME + " " + rModel.CUSTOMER.C_LASTNAME), new ReportParameter("ADDR", rModel.CUSTOMER.C_ADDRESS), new ReportParameter("TEL", rModel.CUSTOMER.C_TEL + " " + (rModel.CUSTOMER.C_EMAIL.Equals("")?" ":" Email :" + rModel.CUSTOMER.C_EMAIL)), new ReportParameter("REP_ID", rModel.REPAIR_NO.ToString()), new ReportParameter("REP_PRODUCT", rModel.PRODUCT.TYPE.PRO_TYPE_NAME + " " + rModel.PRODUCT.BANRD.PRO_BAND_NAME + " " + rModel.MODEL + " สี :" + rModel.COLOR), new ReportParameter("DAMAGE", rModel.DAMAGE) }; ReportDataSource rds = new ReportDataSource("DataSetRepairing", data); lr.SetParameters(pr); lr.DataSources.Add(rds); string reportType = t; string mimeType; string encoding; string fileNameExtension; string deviceInfoA4 = "<DeviceInfo>" + " <OutputFormat>" + t + "</OutputFormat>" + " <PageWidth>21cm</PageWidth>" + " <PageHeight>29.7cm</PageHeight>" + " <MarginTop>1cm</MarginTop>" + " <MarginLeft>0.5in</MarginLeft>" + " <MarginRight>0.5in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; renderedBytes = lr.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(File(renderedBytes, mimeType)); }
[Produces("application/xml")] //強制回傳設定格式 //[Consumes("application/xml")] //強制只接收設定格式 public async Task <IActionResult> Post([FromBody] Root root) { var userName = root.UsrID; AppUserModel ur = _context.AppUsers.Where(u => u.UserName == userName).FirstOrDefault(); if (ur != null) //Check is UserName exist { //string DESKey = "12345678"; //string userPW = DESDecrypt(root.Passwd, DESKey); //DES decrypt. Boolean CheckPassWord = true; //// WebApi to check password. //HttpClient client = new HttpClient(); //client.BaseAddress = new Uri("http://dms.cch.org.tw:8080/"); //string url = "WebApi/Accounts/CheckPasswdForCch?id=" + root.UsrID; //url += "&pwd=" + HttpUtility.UrlEncode(userPW, Encoding.GetEncoding("UTF-8")); //client.DefaultRequestHeaders.Accept.Clear(); //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //HttpResponseMessage response = await client.GetAsync(url); //string rstr = ""; //if (response.IsSuccessStatusCode) //{ // rstr = await response.Content.ReadAsStringAsync(); //} //client.Dispose(); //// //if (rstr.Contains("成功")) //彰基2000帳號WebApi登入 //{ // CheckPassWord = true; //} //else //外包帳號 or 值班帳號 //{ // /* Check and get external user. */ // var ExternalUser = _context.ExternalUsers.Where(ex => ex.UserName == root.UsrID).FirstOrDefault(); // if (ExternalUser != null && ExternalUser.Password == userPW) // { // CheckPassWord = true; // } //} if (CheckPassWord == true) //Check passed. { RepairModel repair = new RepairModel(); var dpt = _dptRepo.Find(d => d.DptId == "8410").FirstOrDefault(); var accdpt = _dptRepo.Find(d => d.DptId == "9390").FirstOrDefault(); var troDes = root.Building + root.Floor + root.Point + root.Area + "," + root.Name + root.Des; repair.DocId = GetID2(); repair.UserId = ur.Id; repair.UserName = ur.FullName; repair.UserAccount = ur.UserName; repair.DptId = dpt.DptId; repair.DptName = dpt.Name_C; repair.AccDpt = accdpt.DptId; repair.AccDptName = accdpt.Name_C; repair.ApplyDate = DateTime.Now; repair.LocType = "本單位"; repair.RepType = "請修"; repair.Ext = ur.Ext == null ? "" : ur.Ext; repair.TroubleDes = "【事件處理編號:" + root.SerNo + "】" + "\n" + troDes; repair.AssetNo = root.Point; repair.AssetName = root.Name; repair.Building = "6"; repair.Floor = "612"; repair.Area = "8410"; // 用XML傳入的工程師名稱尋找負責工程師ID var engs = roleManager.GetUsersInRole("RepEngineer").ToList(); int engId = _context.AppUsers.Where(a => a.UserName == "181316").FirstOrDefault().Id; foreach (string l in engs) { var u = _context.AppUsers.Where(a => a.UserName == l).FirstOrDefault(); if (u != null) { if (u.FullName == root.Manager) { engId = u.Id; } } } repair.EngId = engId; repair.CheckerId = ur.Id; /* 如有代理人,將工程師改為代理人*/ var subStaff = _context.EngSubStaff.SingleOrDefault(e => e.EngId == repair.EngId); if (subStaff != null) { int startDate = Convert.ToInt32(subStaff.StartDate.ToString("yyyyMMdd")); int endDate = Convert.ToInt32(subStaff.EndDate.ToString("yyyyMMdd")); int today = Convert.ToInt32(DateTime.UtcNow.AddHours(08).ToString("yyyyMMdd")); /* 如在代理期間內,將代理人指定為負責工程師 */ if (today >= startDate && today <= endDate) { repair.EngId = subStaff.SubstituteId; } } string msg = ""; try { // Create Repair Doc. repair.ApplyDate = DateTime.Now; _repRepo.Create(repair); // Create Repair Details. RepairDtlModel dtl = new RepairDtlModel(); dtl.DocId = repair.DocId; dtl.DealState = 1; // 處理狀態"未處理" _repdtlRepo.Create(dtl); //Create first Repair Flow. RepairFlowModel flow = new RepairFlowModel(); flow.DocId = repair.DocId; flow.StepId = 1; flow.UserId = ur.Id; flow.Status = "1"; // 流程狀態"已處理" flow.Rtp = ur.Id; flow.Rtt = DateTime.Now; flow.Cls = "申請人"; _repflowRepo.Create(flow); // Create next flow. flow = new RepairFlowModel(); flow.DocId = repair.DocId; flow.StepId = 2; flow.UserId = repair.EngId; flow.Status = "?"; // 狀態"未處理" flow.Rtt = DateTime.Now; flow.Cls = "工務/營建工程師"; _repflowRepo.Create(flow); Root successXML = new Root { Code = "0", Msg = "Success", SerNo = root.SerNo, Mno = repair.DocId }; return(Ok(successXML)); } catch (Exception ex) { msg = ex.Message; } Root errorXMLMsg = new Root { Code = "400", Msg = msg, SerNo = root.SerNo, Mno = "" }; return(BadRequest(errorXMLMsg)); } else { Root errorXMLMsg = new Root { Code = "400", Msg = "PassWord is incorrect.", SerNo = root.SerNo, Mno = "" }; return(BadRequest(errorXMLMsg)); } } else { Root errorXMLMsg = new Root { Code = "400", Msg = "UserID is not exist.", SerNo = root.SerNo, Mno = "" }; return(BadRequest(errorXMLMsg)); } }
public Result AddRepairInfo(RepairModel model) { return(_repairService.AddRepairInfo(model)); }
public IActionResult NewRepair(RepairModel newRepair) { _repairs.Add(newRepair); return(Ok()); }
public Result UpdateRepairInfo(RepairModel model) { return(_repairService.UpdateRepairInfo(model)); }
private void RepairForm_Click(object sender, EventArgs e) { RepairModel.reset(); clearInputs(); }
// PUT: api/Repair/5 public void Put([FromBody] RepairModel value) { new RepairService().AddOrUpdate(value); }