// // GET: /BuyEvaluate/Edit/5 public IActionResult Edit(string id = null, string sid = null) { BuyEvaluateModel buyevaluate = _context.BuyEvaluates.Find(id); if (buyevaluate == null) { return(NotFound()); } buyevaluate.DocSid = sid; if (buyevaluate.AgreeDate != null) { buyevaluate.IsAgree = true; } DepartmentModel d = _context.Departments.Find(buyevaluate.AccDpt); if (d != null) { buyevaluate.AccDptNam = d.Name_C; } AppUserModel u = _context.AppUsers.Find(buyevaluate.EngId); if (u != null) { buyevaluate.EngName = u.FullName; } BudgetModel bgt = _context.Budgets.Find(buyevaluate.BudgetId); if (bgt != null) { buyevaluate.Opinion = bgt.Opinion; buyevaluate.GrpOpin = bgt.GrpOpin; } return(View(buyevaluate)); }
// // GET: /Delivery/Edit/5 public IActionResult Edit(string id = null) { DeliveryModel delivery = _context.Deliveries.Find(id); if (delivery == null) { return(NotFound()); } DepartmentModel c = _context.Departments.Find(delivery.AccDpt); if (c != null) { delivery.AccDptNam = c.Name_C; } VendorModel v = _context.BMEDVendors.Where(vv => vv.UniteNo == delivery.VendorId).FirstOrDefault(); if (v != null) { delivery.VendorNam = v.VendorName; } AppUserModel u = _context.AppUsers.Find(Convert.ToInt32(delivery.DelivPson)); if (u != null) { delivery.DelivPsonNam = u.FullName; } BuyEvaluateModel b = _context.BuyEvaluates.Find(delivery.PurchaseNo); if (b != null) { delivery.BudgetId = b.BudgetId; } return(View(delivery)); }
public IActionResult UpdAgreeDate(string docid, bool isagree) { try { BuyEvaluateModel buyeval = _context.BuyEvaluates.Find(docid); if (isagree) { buyeval.AgreeDate = DateTime.Now; } else { buyeval.AgreeDate = null; } _context.Entry(buyeval).State = EntityState.Modified; _context.SaveChanges(); return(new JsonResult(buyeval) { Value = new { success = true, error = "" }, }); } catch (Exception e) { throw new Exception(e.Message); } }
// // GET: /BuyEvaluate/Create public IActionResult Create() { // Get Login User's details. var u = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault(); BuyEvaluateModel r = new BuyEvaluateModel(); DepartmentModel d = _context.Departments.Find(u.DptId); VendorModel v = _context.BMEDVendors.Find(u.VendorId); r.DocId = r.GetID(ref _context); r.UserId = u.Id; r.UserName = u.FullName; r.Company = d.DptId == null ? "" : d.Name_C; r.AccDpt = d.DptId == null ? "" : d.DptId; r.AccDptNam = d.DptId == null ? "" : d.Name_C; r.Contact = u.Mobile; r.PlantType = "醫療儀器"; r.Place = r.AccDptNam; r.Rtt = DateTime.Now; _context.BuyEvaluates.Add(r); _context.SaveChanges(); List <SelectListItem> listItem = new List <SelectListItem>(); List <SelectListItem> listItem2 = new List <SelectListItem>(); List <SelectListItem> listItem3 = new List <SelectListItem>(); listItem3.Add(new SelectListItem { Text = "醫療儀器", Value = "醫療儀器" }); listItem3.Add(new SelectListItem { Text = "資訊設備", Value = "資訊設備" }); ViewData["PTYPE"] = new SelectList(listItem3, "Value", "Text", "醫療儀器"); string[] eng = roleManager.GetUsersInRole("MedEngineer"); string[] buyer = roleManager.GetUsersInRole("Buyer"); AppUserModel p; foreach (string s in eng) { p = _context.AppUsers.Where(ur => ur.UserName == s).FirstOrDefault(); if (p != null) { listItem.Add(new SelectListItem { Text = "(" + p.UserName + ")" + p.FullName, Value = p.Id.ToString() }); } } ViewData["ENG"] = new SelectList(listItem, "Value", "Text"); // foreach (string s2 in buyer) { p = _context.AppUsers.Where(ur => ur.UserName == s2).FirstOrDefault(); if (p != null) { listItem2.Add(new SelectListItem { Text = "(" + p.UserName + ")" + p.FullName, Value = p.Id.ToString() }); } } ViewData["PUR"] = new SelectList(listItem2, "Value", "Text"); return(View(r)); }
public IActionResult Edit(BuyEvaluateModel buyevaluate) { if (ModelState.IsValid) { _context.Entry(buyevaluate).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(buyevaluate)); }
// // GET: /BuyEvaluate/Delete/5 public IActionResult Delete(string id = null) { BuyEvaluateModel buyevaluate = _context.BuyEvaluates.Find(id); if (buyevaluate == null) { return(NotFound()); } return(View(buyevaluate)); }
public IActionResult Update(BuyEvaluateModel buyevaluate) { if (ModelState.IsValid) { _context.Entry(buyevaluate).State = EntityState.Modified; _context.SaveChanges(); return(new JsonResult(buyevaluate) { Value = new { success = true, error = "" }, }); } return(View(buyevaluate)); }
// public IActionResult Update(string id) { BuyEvaluateModel buyevaluate = _context.BuyEvaluates.Find(id); if (buyevaluate == null) { return(NotFound()); } DepartmentModel d = _context.Departments.Find(buyevaluate.AccDpt); if (d != null) { buyevaluate.AccDptNam = d.Name_C; } AppUserModel u = _context.AppUsers.Find(buyevaluate.EngId); if (u != null) { buyevaluate.EngName = u.FullName; } List <SelectListItem> listItem = new List <SelectListItem>(); List <SelectListItem> listItem2 = new List <SelectListItem>(); string[] eng = roleManager.GetUsersInRole("Engineer"); string[] buyer = roleManager.GetUsersInRole("Buyer"); AppUserModel p; foreach (string s in eng) { p = _context.AppUsers.Where(ur => ur.UserName == s).FirstOrDefault(); if (p != null) { listItem.Add(new SelectListItem { Text = "(" + p.UserName + ")" + p.FullName, Value = p.Id.ToString() }); } } ViewData["ENG"] = new SelectList(listItem, "Value", "Text"); // listItem2.Add(new SelectListItem { Text = "醫療儀器", Value = "醫療儀器" }); listItem2.Add(new SelectListItem { Text = "資訊設備", Value = "資訊設備" }); ViewData["PTYPE"] = new SelectList(listItem2, "Value", "Text", "醫療儀器"); // return(View(buyevaluate)); }
// // GET: /BuyEvaluate/Details/5 public IActionResult Details(string id = null) { BuyEvaluateModel buyevaluate = _context.BuyEvaluates.Find(id); if (buyevaluate == null) { return(NotFound()); } buyevaluate.EngName = _context.AppUsers.Find(buyevaluate.EngId).FullName; var dpt = _context.Departments.Find(buyevaluate.AccDpt); if (dpt != null) { buyevaluate.AccDptNam = dpt.Name_C; } return(View(buyevaluate)); }
public IActionResult DeleteConfirmed(string id) { BuyEvaluateModel buyevaluate = _context.BuyEvaluates.Find(id); if (buyevaluate == null) { return(NotFound()); } _context.BuyEvaluates.Remove(buyevaluate); List <BuyFlowModel> bf = _context.BuyFlows.Where(f => f.DocId == id).ToList(); foreach (BuyFlowModel f in bf) { _context.BuyFlows.Remove(f); } _context.SaveChanges(); return(RedirectToAction("Index", "Members")); }
public string UpdStandard(string docid, string standard) { if (standard != null) { try { BuyEvaluateModel buyeval = _context.BuyEvaluates.Find(docid); buyeval.Standard = standard; _context.Entry(buyeval).State = EntityState.Modified; _context.SaveChanges(); return("儲存成功!"); } catch (Exception e) { return(e.Message); } } return("無規格資料!"); }
// // GET: /Delivery/Create public IActionResult Create(string id = null) { DeliveryModel r = new DeliveryModel(); // Get Login User's details. var u = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault(); DepartmentModel c = _context.Departments.Find(u.DptId); VendorModel v = _context.BMEDVendors.Find(u.VendorId); if (id != null) { BuyEvaluateModel b = _context.BuyEvaluates.Find(id); if (b != null) { r.EngId = b.EngId; r.BudgetId = b.BudgetId; int a = 0; if (int.TryParse(b.AccDpt, out a)) { c = _context.Departments.Find(b.AccDpt); if (c != null) { r.AccDpt = c.DptId; r.AccDptNam = c.Name_C; } } else { c = _context.Departments.Where(d => d.Name_C == b.AccDpt).FirstOrDefault(); if (c != null) { r.AccDpt = c.DptId; r.AccDptNam = c.Name_C; } } } } r.DocId = GetID(); r.UserId = u.Id; r.UserName = u.FullName; c = _context.Departments.Find(u.DptId); if (c != null) { r.Company = c.DptId == null ? "" : c.Name_C; if (r.AccDpt == null) { r.AccDpt = c.DptId == null ? "" : c.DptId; r.AccDptNam = c.DptId == null ? "" : c.Name_C; } } r.Contact = u.Mobile; r.ApplyDate = DateTime.Now; r.PurchaseNo = id; r.WartyMon = 0; r.DelivDateR = DateTime.Now; _context.Deliveries.Add(r); _context.SaveChanges(); List <SelectListItem> listItem = new List <SelectListItem>(); List <SelectListItem> listItem2 = new List <SelectListItem>(); List <SelectListItem> listItem3 = new List <SelectListItem>(); List <SelectListItem> listItem4 = new List <SelectListItem>(); List <SelectListItem> listItem5 = new List <SelectListItem>(); var eng = roleManager.GetUsersInRole("MedEngineer").ToList(); var buyer = roleManager.GetUsersInRole("Buyer"); AppUserModel p; foreach (string s in eng) { p = _context.AppUsers.Where(ur => ur.UserName == s).FirstOrDefault(); if (p.Status == "Y") { listItem.Add(new SelectListItem { Text = "(" + p.UserName + ")" + p.FullName, Value = p.Id.ToString() }); } } ViewData["ENG"] = new SelectList(listItem, "Value", "Text"); // foreach (string s2 in buyer) { p = _context.AppUsers.Where(ur => ur.UserName == s2).FirstOrDefault(); listItem2.Add(new SelectListItem { Text = p.FullName, Value = p.Id.ToString() }); } ViewData["PUR"] = new SelectList(listItem2, "Value", "Text"); List <BuyVendorModel> bv = _context.BuyVendors.Where(t => t.DocId == id).ToList(); foreach (BuyVendorModel b in bv) { listItem3.Add(new SelectListItem { Text = b.VendorNam, Value = b.UniteNo }); } ViewData["Vendors"] = new SelectList(listItem3, "Value", "Text"); // //List<objuser> uv = _context.AppUsers.Join(_context.Departments, up => up.DptId, co => co.DptId, // (up, co) => new objuser // { // uid = up.UserId, // uname = up.FullName, // gid = co.GroupId // }).Where(co => co.gid == c.GroupId).ToList(); List <AppUserModel> uv = _context.AppUsers.ToList(); uv = uv.OrderBy(urs => urs.UserName).ToList(); foreach (AppUserModel z in uv) { listItem4.Add(new SelectListItem { Text = "(" + z.UserName + ")" + z.FullName, Value = z.Id.ToString() }); } ViewData["Users"] = new SelectList(listItem4, "Value", "Text"); ViewData["Item2"] = new SelectList(listItem5, "Value", "Text"); return(View(r)); }
public JsonResult GetNextEmp(string cls = null, string docid = null, string vendor = null) { // Get Login User's details. var loginUser = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault(); List <SelectListItem> list = null; List <string> s; SelectListItem li; AppUserModel u; BuyEvaluateModel r = _context.BuyEvaluates.Find(docid); string c = _context.AppUsers.Find(loginUser.Id).DptId; //string g = _context.Departments.Find(c).GroupId; //string g = _context.CustOrgans.Find(_context.UserProfiles.Find(r.UserId).CustId).GroupId; switch (cls) { case "設備工程師": //s = Roles.GetUsersInRole("Engineer").ToList(); list = new List <SelectListItem>(); AppUserModel u2 = _context.AppUsers.Find(r.EngId); li = new SelectListItem(); li.Text = "(" + u2.UserName + ")" + u2.FullName; li.Value = u2.Id.ToString(); list.Add(li); break; case "資訊工程師": list = new List <SelectListItem>(); s = roleManager.GetUsersInRole("IT_Engineer").ToList(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (u != null) { if (u.Status == "Y") { li = new SelectListItem(); li.Text = "(" + u.UserName + ")" + u.FullName; li.Value = u.Id.ToString(); list.Add(li); } } } break; //case "評估工程師": // list = new List<SelectListItem>(); // s = roleManager.GetUsersInRole("MedEngineer").ToList(); // foreach (string l in s) // { // u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); // if (u != null) // { // li = new SelectListItem(); // li.Text = "(" + u.UserName + ")" + u.FullName; // li.Value = u.Id.ToString(); // list.Add(li); // } // } // break; case "設備主管": list = new List <SelectListItem>(); s = roleManager.GetUsersInRole("MedMgr").ToList(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (u != null) { if (u.Status == "Y") { li = new SelectListItem(); li.Text = "(" + u.UserName + ")" + u.FullName; li.Value = u.Id.ToString(); list.Add(li); } } } break; case "採購主管": s = roleManager.GetUsersInRole("BuyerMgr").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (u != null) { li = new SelectListItem(); li.Text = "(" + u.UserName + ")" + u.FullName; li.Value = u.Id.ToString(); list.Add(li); } } break; case "單位主管": s = roleManager.GetUsersInRole("Manager").ToList(); c = _context.AppUsers.Find(r.UserId).DptId; list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (u != null) { DepartmentModel o = _context.Departments.Find(u.DptId); if (u.DptId == c) { li = new SelectListItem(); li.Text = "(" + u.UserName + ")" + u.FullName; li.Value = u.Id.ToString(); list.Add(li); } } } break; case "設備經辦": s = roleManager.GetUsersInRole("MedToDo").ToList(); list = new List <SelectListItem>(); foreach (string l in s) { u = _context.AppUsers.Where(ur => ur.UserName == l).FirstOrDefault(); if (u != null) { if (u.Status == "Y") { li = new SelectListItem(); li.Text = "(" + u.UserName + ")" + u.FullName; li.Value = u.Id.ToString(); list.Add(li); } } } break; case "申請者": if (r != null) { var usr = _context.AppUsers.Find(r.UserId); if (usr != null) { list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = "(" + usr.UserName + ")" + r.UserName; li.Value = r.UserId.ToString(); list.Add(li); } } break; case "採購人員": if (r != null) { var pr = _context.AppUsers.Find(r.PurchaserId); if (pr != null) { list = new List <SelectListItem>(); li = new SelectListItem(); li.Text = "(" + pr.UserName + ")" + r.PurchaserName; li.Value = r.PurchaserId.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 (u != null && u.Status == "Y") { DepartmentModel o = _context.Departments.Find(u.DptId); DepartmentModel e = _context.Departments.Where(n => n.Name_C == r.Place).FirstOrDefault(); if (e.Loc == "C" || e.Loc == "P" || e.Loc == "K") { if (o.Loc == "C" || o.Loc == "P" || o.Loc == "K") { li = new SelectListItem(); li.Text = "(" + u.UserName + ")" + u.FullName; li.Value = u.Id.ToString(); list.Add(li); } } else { if (o.Loc != "C" || o.Loc != "P" || o.Loc != "K") { li = new SelectListItem(); li.Text = "(" + u.UserName + ")" + u.FullName; li.Value = u.Id.ToString(); list.Add(li); } } } } break; default: list = new List <SelectListItem>(); break; } return(Json(list)); }
public ActionResult NextFlow(string id = null, string sid = null) { BuyFlowModel rf; if (sid != null) { rf = _context.BuyFlows.Where(f => f.DocId == sid && f.Status == "?").FirstOrDefault(); } else { rf = _context.BuyFlows.Where(f => f.DocId == id && f.Status == "?").FirstOrDefault(); } //rf.Docid = id; List <SelectListItem> listItem = new List <SelectListItem>(); if (sid == null) { 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 (rf.Cls == "設備經辦") { listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } } else { if (rf.Cls == "申請者") { listItem.Add(new SelectListItem { Text = "設備工程師", Value = "設備工程師" }); listItem.Add(new SelectListItem { Text = "廢除", Value = "廢除" }); } else if (rf.Cls == "設備工程師") { listItem.Add(new SelectListItem { Text = "設備主管", Value = "設備主管" }); } else if (rf.Cls == "單位主管") { listItem.Add(new SelectListItem { Text = "申請者", Value = "申請者" }); //listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } else if (rf.Cls == "設備主管") { listItem.Add(new SelectListItem { Text = "設備工程師", Value = "設備工程師" }); listItem.Add(new SelectListItem { Text = "設備經辦", Value = "設備經辦" }); //listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } else if (rf.Cls == "設備經辦") { listItem.Add(new SelectListItem { Text = "設備主管", Value = "設備主管" }); listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } } ViewData["Item"] = new SelectList(listItem, "Value", "Text", ""); // List <SelectListItem> listItem2 = new List <SelectListItem>(); listItem2.Add(new SelectListItem { Text = "", Value = "" }); ViewData["Item2"] = new SelectList(listItem2, "Value", "Text", ""); rf.Cls = ""; // BuyEvaluateModel ra = _context.BuyEvaluates.Find(id); if (ra != null) { string cid = _context.AppUsers.Find(ra.UserId).DptId; //string gid = _context.Departments.Find(cid).GroupId; //if (gid != null) //{ // rf.FlowHint = _context.Groups.Find(gid).FlowHint3; //} } rf.SelOpin = "同意"; return(PartialView(rf)); }
public ActionResult InEvaluate(string docid = null) { BuyFlowModel buyflow = _context.BuyFlows.Where(b => b.DocId == docid) .Where(b => b.Status == "?").FirstOrDefault(); if (buyflow == null) { return(NotFound()); } else { buyflow.Status = "E"; buyflow.Rtt = DateTime.Now; _context.Entry(buyflow).State = EntityState.Modified; // BuyEvaluateModel e = _context.BuyEvaluates.Find(docid); BuySFlowModel s = new BuySFlowModel(); s.DocId = docid; s.DocSid = buyflow.DocId + "_1"; s.StepId = 2; s.Status = "?"; s.Rtp = buyflow.UserId; s.Rtt = DateTime.Now; _context.BuySFlows.Add(s); BuySFlowModel s2 = new BuySFlowModel(); s2.DocId = docid; s2.DocSid = buyflow.DocId + "_2"; s2.StepId = 2; s2.Status = "?"; s2.Rtp = buyflow.UserId; s2.Rtt = DateTime.Now; _context.BuySFlows.Add(s2); // BuyFlowModel bf = new BuyFlowModel(); BuyFlowModel bf2 = new BuyFlowModel(); bf.DocId = buyflow.DocId + "_1"; bf2.DocId = buyflow.DocId + "_2"; bf.StepId = 1; bf2.StepId = 1; bf.UserId = buyflow.UserId; bf2.UserId = buyflow.UserId; bf.Status = "1"; bf2.Status = "1"; bf.Cls = "採購人員"; bf2.Cls = "採購人員"; bf.Rtp = buyflow.UserId; bf2.Rtp = buyflow.UserId; bf.Rtt = DateTime.Now; bf2.Rtt = DateTime.Now; _context.Entry(buyflow).State = EntityState.Modified; _context.BuyFlows.Add(bf); _context.BuyFlows.Add(bf2); // bf.StepId = 2; bf2.StepId = 2; bf.UserId = e.UserId; bf2.UserId = e.EngId; bf.Status = "?"; bf2.Status = "?"; bf.Cls = "申請者"; bf2.Cls = "維修工程師"; bf.Rtp = buyflow.UserId; bf2.Rtp = buyflow.UserId; bf.Rtt = DateTime.Now; bf2.Rtt = DateTime.Now; _context.BuyFlows.Add(bf); _context.BuyFlows.Add(bf2); _context.SaveChanges(); } return(RedirectToAction("Index", "Home", new { Area = "" })); }
public IActionResult TransToBuyEvaluate() { // Get Login User's details. var user = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault(); String[] st = { "?", "2" }; var s = _context.BuyFlows.Where(b => st.Contains(b.Status)) .Join(_context.BuyEvaluates, b => b.DocId, e => e.DocId, (b, e) => e).Where(e => !string.IsNullOrEmpty(e.BudgetId)) .Select(e => e.BudgetId).Distinct(); List <BudgetModel> bs = _context.Budgets.Where(b => !s.Contains(b.DocId)).ToList(); BuyEvaluateModel r; BuyFlowModel rf; Tmail mail; string body = ""; AppUserModel a = _context.AppUsers.Find(user.Id); AppUserModel u; DepartmentModel c = _context.Departments.Find(a.DptId); int dc = 0; foreach (BudgetModel b in bs) { r = new BuyEvaluateModel(); if (dc <= 0) { dc = Convert.ToInt32(r.GetID(ref _context)); } else { dc++; } r.DocId = Convert.ToString(dc); r.PlantCnam = b.PlantName; r.PlantEnam = b.PlantName; r.Standard = b.Standard; r.Price = b.Price; r.Amt = b.Amt; r.Unit = b.Unit; r.TotalPrice = b.TotalPrice; r.UserId = a.Id; r.UserName = a.FullName; r.Company = c.DptId == null ? "" : c.Name_C; r.AccDpt = b.AccDpt == null ? "" : b.AccDpt; r.AccDptNam = _context.Departments.Find(b.AccDpt) == null ? "" : _context.Departments.Find(b.AccDpt).Name_C; r.Contact = a.Mobile; r.PlantType = "醫療儀器"; r.Place = r.AccDptNam; if (_context.AppUsers.Where(up => up.FullName == b.EngName && up.Status == "Y").FirstOrDefault() == null) { throw new Exception("無工程師[" + b.EngName + "]資料!!請建立使用者資料。"); } r.EngId = _context.AppUsers.Where(up => up.FullName == b.EngName && up.Status == "Y").FirstOrDefault() == null ? user.Id : _context.AppUsers.Where(up => up.FullName == b.EngName && up.Status == "Y").FirstOrDefault().Id; r.Rtp = a.Id; r.Rtt = DateTime.Now; r.BudgetId = b.DocId; _context.BuyEvaluates.Add(r); // rf = new BuyFlowModel(); rf.DocId = r.DocId; rf.StepId = 1; rf.UserId = user.Id; rf.Status = "1"; rf.Role = roleManager.GetRolesForUser(user.Id).GetValue(0).ToString(); rf.Rtp = user.Id; rf.Rdt = null; rf.Rtt = DateTime.Now; rf.Cls = "申請者"; _context.BuyFlows.Add(rf); // rf = new BuyFlowModel(); rf.DocId = r.DocId; rf.StepId = 2; rf.UserId = r.EngId; rf.Status = "?"; u = _context.AppUsers.Find(r.EngId); rf.Role = roleManager.GetRolesForUser(u.Id).FirstOrDefault(); rf.Rtp = null; rf.Rdt = null; rf.Rtt = DateTime.Now; rf.Cls = "設備工程師"; _context.BuyFlows.Add(rf); // try { _context.SaveChanges(); // mail = new Tmail(); body = ""; u = _context.AppUsers.Find(user.Id); mail.from = new System.Net.Mail.MailAddress(u.Email); //u.Email u = _context.AppUsers.Find(rf.UserId); mail.to = new System.Net.Mail.MailAddress(u.Email); //u.Email //mail.cc = new System.Net.Mail.MailAddress("*****@*****.**"); mail.message.Subject = "醫療儀器管理資訊系統[採購評估案]:儀器名稱: " + r.PlantCnam; body += "<p>申請人:" + r.UserName + "</p>"; body += "<p>儀器名稱:" + r.PlantCnam + "</p>"; body += "<p><a href='http://dms.cch.org.tw/MvcMedEngMgr'>處理案件</a></p>"; body += "<br/>"; body += "<h3>this is a inform letter from system manager.Do not reply for it.</h3>"; mail.message.Body = body; mail.message.IsBodyHtml = true; //mail.SendMail(); } catch (Exception e) { throw new Exception(e.Message); } } return(new JsonResult(bs) { Value = new { success = true, error = "" }, }); }
public async Task <IViewComponentResult> InvokeAsync(string id = null, string sid = null) { BuyFlowModel rf; if (sid != null) { rf = _context.BuyFlows.Where(bf => bf.DocId == sid && bf.Status == "?").ToList().FirstOrDefault(); } else { rf = _context.BuyFlows.Where(bf => bf.DocId == id && bf.Status == "?").ToList().FirstOrDefault(); } List <SelectListItem> listItem = new List <SelectListItem>(); if (sid == null) { 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 (rf.Cls == "設備經辦") { listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } } else { if (rf.Cls == "申請者") { listItem.Add(new SelectListItem { Text = "設備工程師", Value = "設備工程師" }); listItem.Add(new SelectListItem { Text = "廢除", Value = "廢除" }); } else if (rf.Cls == "設備工程師") { listItem.Add(new SelectListItem { Text = "設備主管", Value = "設備主管" }); } else if (rf.Cls == "單位主管") { listItem.Add(new SelectListItem { Text = "申請者", Value = "申請者" }); //listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } else if (rf.Cls == "設備主管") { listItem.Add(new SelectListItem { Text = "設備工程師", Value = "設備工程師" }); listItem.Add(new SelectListItem { Text = "設備經辦", Value = "設備經辦" }); //listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } else if (rf.Cls == "設備經辦") { listItem.Add(new SelectListItem { Text = "設備主管", Value = "設備主管" }); listItem.Add(new SelectListItem { Text = "結案", Value = "結案" }); } } ViewData["Item"] = new SelectList(listItem, "Value", "Text", ""); // List <SelectListItem> listItem2 = new List <SelectListItem>(); listItem2.Add(new SelectListItem { Text = "", Value = "" }); ViewData["Item2"] = new SelectList(listItem2, "Value", "Text", ""); rf.Cls = ""; // BuyEvaluateModel ra = _context.BuyEvaluates.Find(id); if (ra != null) { string cid = _context.AppUsers.Find(ra.UserId).DptId; } rf.SelOpin = "同意"; return(View(rf)); }
public List <DeliveryListVModel> GetList(string cls = null) { List <DeliveryListVModel> dv = new List <DeliveryListVModel>(); List <DelivFlowModel> rf = new List <DelivFlowModel>(); List <DelivFlowModel> rf2; // Get Login User's details. var ur = _userRepo.Find(usr => usr.UserName == User.Identity.Name).FirstOrDefault(); switch (cls) { case "已處理": rf2 = _context.DelivFlows.FromSql("SELECT * FROM BMEDDELIVFLOWS WHERE STATUS ='?'") .Where(m => m.UserId != ur.Id).ToList(); if (userManager.IsInRole(User, "MedToDo")) { rf.AddRange(rf2); } else { foreach (DelivFlowModel f in rf2) { if (_context.DelivFlows.Where(m => m.DocId == f.DocId).Where(m => m.UserId == ur.Id).Count() > 0) { rf.Add(f); } } } break; case "已結案": rf2 = _context.DelivFlows.FromSql("SELECT * FROM BMEDDELIVFLOWS WHERE STATUS ='2'").ToList(); if (userManager.IsInRole(User, "MedToDo")) { rf.AddRange(rf2); } else { foreach (DelivFlowModel f in rf2) { if (_context.DelivFlows.Where(m => m.DocId == f.DocId).Where(m => m.UserId == ur.Id).Count() > 0) { rf.Add(f); } } } break; case "查詢": rf2 = _context.DelivFlows.FromSql("SELECT * FROM BMEDDELIVFLOWS WHERE STATUS ='?'").ToList(); DeliveryModel r; foreach (DelivFlowModel f in rf2) { r = _context.Deliveries.Find(f.DocId); rf.Add(f); } break; default: rf = _context.DelivFlows.FromSql("SELECT * FROM BMEDDELIVFLOWS WHERE STATUS ='?'") .Where(m => m.UserId == ur.Id).ToList(); break; } rf.OrderByDescending(m => m.Rtt); DeliveryListVModel i; foreach (DelivFlowModel f in rf) { DeliveryModel r = _context.Deliveries.Find(f.DocId); AppUserModel p = _context.AppUsers.Find(r.UserId); DepartmentModel c = _context.Departments.Find(p.DptId); BuyEvaluateModel b = _context.BuyEvaluates.Find(r.PurchaseNo); i = new DeliveryListVModel(); i.DocType = "驗收"; i.DocId = r.DocId; i.UserId = r.UserId; i.UserName = r.UserName; if (p != null && p.DptId != null) { i.Company = p.DptId; i.CompanyNam = c == null ? "" : c.Name_C; } i.ContractNo = r.ContractNo; i.PurchaseNo = r.PurchaseNo; i.CrlItemNo = r.CrlItemNo; i.AccDpt = r.AccDpt; i.AccDptNam = _context.Departments.Find(r.AccDpt) == null ? "" : _context.Departments.Find(r.AccDpt).Name_C; i.BudgetId = ""; if (f.Status == "?") { i.Days = DateTime.Now.Subtract(r.ApplyDate.GetValueOrDefault()).Days; } else { i.Days = null; } i.Flg = f.Status; i.FlowUid = f.UserId; i.ApplyDate = r.ApplyDate; dv.Add(i); } // return(dv); }
public IActionResult Create(BuyEvaluateModel buyevaluate) { if (ModelState.IsValid) { // Get Login User's details. var user = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault(); DepartmentModel dpt = _context.Departments.Where(d => d.Name_C == buyevaluate.AccDptNam).FirstOrDefault(); if (dpt != null) { buyevaluate.AccDpt = dpt.DptId; } else { ModelState.AddModelError("", "成本中心無此資料!!"); return(View(buyevaluate)); } buyevaluate.Rtp = user.Id; buyevaluate.Rtt = DateTime.Now; _context.Entry(buyevaluate).State = EntityState.Modified; // BuyFlowModel rf = new BuyFlowModel(); rf.DocId = buyevaluate.DocId; rf.StepId = 1; rf.UserId = user.Id; rf.Status = "1"; rf.Role = roleManager.GetRolesForUser(user.Id).GetValue(0).ToString(); rf.Rtp = user.Id; rf.Rdt = null; rf.Rtt = DateTime.Now; rf.Cls = "申請者"; _context.BuyFlows.Add(rf); // rf = new BuyFlowModel(); rf.DocId = buyevaluate.DocId; rf.StepId = 2; rf.UserId = buyevaluate.EngId; rf.Status = "?"; AppUserModel u = _context.AppUsers.Find(buyevaluate.EngId); rf.Role = roleManager.GetRolesForUser(u.Id).FirstOrDefault(); rf.Rtp = null; rf.Rdt = null; rf.Rtt = DateTime.Now; rf.Cls = "設備工程師"; _context.BuyFlows.Add(rf); // _context.SaveChanges(); // Tmail mail = new Tmail(); string body = ""; u = _context.AppUsers.Find(user.Id); mail.from = new System.Net.Mail.MailAddress(u.Email); //u.Email u = _context.AppUsers.Find(buyevaluate.PurchaserId); mail.to = new System.Net.Mail.MailAddress(u.Email); //u.Email //mail.cc = new System.Net.Mail.MailAddress("*****@*****.**"); mail.message.Subject = "醫療儀器管理資訊系統[採購評估案]:儀器名稱: " + buyevaluate.PlantCnam; body += "<p>申請人:" + buyevaluate.UserName + "</p>"; body += "<p>儀器名稱:" + buyevaluate.PlantCnam + "</p>"; body += "<p><a href='http://dms.cch.org.tw/MvcMedEngMgr'>處理案件</a></p>"; body += "<br/>"; body += "<h3>this is a inform letter from system manager. Do not reply for it.</h3>"; mail.message.Body = body; mail.message.IsBodyHtml = true; //mail.SendMail(); return(RedirectToAction("Index", "Home", new { Area = "" })); } return(View(buyevaluate)); }