public ActionResult AddRoleUser(int?RoleId, string BadgeCode, string Description) { if (RoleId.HasValue && BadgeCode != null) { if (BadgeCode.Trim().Length >= 9) { BadgeCode = BadgeCode.Trim().ToUpper(); var currroleuser = db.UserRole.ToList().Where(x => x.BadgeCode == BadgeCode && x.RoleId == int.Parse(RoleId.ToString())).Select(x => x.id); var existuser = db.userprofile.Where(x => x.BadgeCode == BadgeCode).Select(x => x.BadgeCode); if (existuser != null && existuser.Count() > 0) { if (currroleuser.Count() == 0) { db.UserRole.Add(new UserRole() { RoleId = int.Parse(RoleId.ToString()), BadgeCode = BadgeCode, Description = Description }); } else { UserRole userrole = (UserRole)db.UserRole.ToList().Where(x => x.BadgeCode == BadgeCode && int.Parse(x.RoleId.ToString()) == RoleId).FirstOrDefault(); userrole.Description = Description; db.Entry(userrole).State = EntityState.Modified; } db.SaveChanges(); } } } return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult Edit(ProcessStep processstep) { if (ModelState.IsValid) { db.Entry(processstep).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(processstep)); }
public ActionResult Edit(CustomerName customername) { if (ModelState.IsValid) { db.Entry(customername).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customername)); }
public ActionResult Edit(ReturnType returntype) { if (ModelState.IsValid) { db.Entry(returntype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(returntype)); }
public ActionResult Edit(IssueSource issuesource) { if (ModelState.IsValid) { db.Entry(issuesource).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(issuesource)); }
public ActionResult Edit(RoleMenu rolemenu) { if (ModelState.IsValid) { db.Entry(rolemenu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rolemenu)); }
public ActionResult Edit(PCBVendor pcbvendor) { if (ModelState.IsValid) { db.Entry(pcbvendor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pcbvendor)); }
public ActionResult Edit(TestPurpose testpurpose) { if (ModelState.IsValid) { db.Entry(testpurpose).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(testpurpose)); }
public ActionResult Edit(ProductStage productstage) { if (ModelState.IsValid) { db.Entry(productstage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productstage)); }
public ActionResult Edit(TestItemMenu testitemmenu) { if (ModelState.IsValid) { db.Entry(testitemmenu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(testitemmenu)); }
public ActionResult Edit(CERLMenu cerlmenu) { string UserId = Method.GetLogonUserId(Session, this, User.Identity.Name.ToUpper()); if (ModelState.IsValid) { cerlmenu.editor = UserId; cerlmenu.udt = System.DateTime.Now; db.Entry(cerlmenu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cerlmenu)); }
public ActionResult Edit(FormCollection fc, f_cerl f_cerl) { if (f_cerl.State >= 1000) { InitDDLShow(null, "EDIT"); return(View(f_cerl)); } string UserId = Constant.LogonUserId; if (ModelState.IsValid) { if (TryUpdateModel(f_cerl, "", fc.AllKeys, new string[] { "cdt" })) { f_cerl = CheckAndPushTask(fc, f_cerl); f_cerl.udt = DateTime.Now; f_cerl.editor = UserId; var r = new List <attachFile>(); int i = 0; foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[i] as HttpPostedFileBase; if (hpf.ContentLength == 0) { continue; } string formId = f_cerl.fID; string state = f_cerl.State.ToString(); string filePath0 = Constant.UserFileDirectory + formId + @"\"; string filePath = Constant.UserFileDirectory + formId + @"\" + state + @"\"; FileInfo newinfo = new FileInfo(hpf.FileName); string savedFileName = Path.Combine(filePath, Path.GetFileName(newinfo.Name)); if (!Directory.Exists(filePath0)) { Directory.CreateDirectory(filePath0); } if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } hpf.SaveAs(savedFileName); int count = db.attachFiles.Where(x => x.fID == formId && x.folderId == state && x.fileName == newinfo.Name).Count(); if (count == 0) { r.Add(new attachFile() { fID = formId, displayname = newinfo.Name, fileName = newinfo.Name, Length = hpf.ContentLength, Type = hpf.ContentType, folderId = state, editor = Constant.LogonUserId, filePath = filePath, cdt = DateTime.Now, udt = DateTime.Now }); } i++; } foreach (attachFile a in r) { db.attachFiles.Add(a); } } db.Entry(f_cerl).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); RouteValueDictionary rv = new RouteValueDictionary(); rv.Add("id", f_cerl.ID); return(RedirectToAction("Details", rv)); //InitDDLShow(); //return RedirectToAction("Index"); } return(View(f_cerl)); }
public ActionResult Edit(FormCollection labInfo, LabInformation labinformation) { CERLDBContext db = new CERLDBContext(); string UserId = Method.GetLogonUserId(Session, this, User.Identity.Name.ToUpper()); string FolderId = "LabInformation"; if (ModelState.IsValid) { labinformation.udt = DateTime.Now; labinformation.editor = UserId; labinformation.Width = (labinformation.Width == null || labinformation.Width.Trim() == "") ? "100%" : labinformation.Width; labinformation.Height = (labinformation.Height == null || labinformation.Height.Trim() == "") ? "100%" : labinformation.Height; var r = new List <attachFile>(); int i = 0; foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[i] as HttpPostedFileBase; if (hpf.ContentLength == 0) { continue; } string formId = labinformation.fID; string filePath = Constant.UserFileDirectory + FolderId + @"\" + formId + @"\"; FileInfo newinfo = new FileInfo(hpf.FileName); string savedFileName = Path.Combine(filePath, Path.GetFileName(newinfo.Name)); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } hpf.SaveAs(savedFileName); int count = db.attachFiles.Where(x => x.fID == formId && x.fileName == newinfo.Name).Count(); if (count == 0) { r.Add(new attachFile() { fID = formId, displayname = newinfo.Name, fileName = newinfo.Name, Length = hpf.ContentLength, Type = hpf.ContentType, folderId = FolderId, editor = UserId, filePath = filePath, cdt = DateTime.Now, udt = DateTime.Now }); } i++; } foreach (attachFile a in r) { db.attachFiles.Add(a); } db.Entry(labinformation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(labinformation)); }
public f_cerl CheckAndPushTask(FormCollection fc, f_cerl f_cerl) { string fnCheckAndPushTask = "RouteWork_CheckAndPushTask"; string UserId = f_cerl.editor; string strAction = f_cerl.Action; string ListAssignTo = ""; int errorline = 233; try { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); StringBuilder vchSet = new StringBuilder(); errorline = 238; FlowPath fp = GetFlowPath(f_cerl.fID, f_cerl.FlowCode, f_cerl.State, f_cerl.Action); // 取得下一關的State errorline = 240; if (fp == null) { return(f_cerl); } if (f_cerl.State >= 1000) { strAction = ""; return(f_cerl); } errorline = 249; if (fp != null) { if (f_cerl.LocalSupervisor == null) { f_cerl.LocalSupervisor = db.vUsers.Where(u => u.RoleId == 20).Select(v => v.BadgeCode).FirstOrDefault();//"IEC970209"; } errorline = 254; if (f_cerl.Manager == null) { f_cerl.Manager = f_cerl.Applicant; } errorline = 257; vchSet.Append(Method.BuildXML(fp.outState.ToString(), "outState")); vchSet.Append(Method.BuildXML(f_cerl.TestItem.ToString(), "TestItem")); vchSet.Append(Method.BuildXML(f_cerl.Supervisor, "Supervisor")); vchSet.Append(Method.BuildXML(f_cerl.LocalSupervisor, "LocalSupervisor")); vchSet.Append(Method.BuildXML(f_cerl.LabMember, "LabMember")); vchSet.Append(Method.BuildXML(f_cerl.Applicant, "Applicant")); vchSet.Append(Method.BuildXML(f_cerl.Manager, "Manager")); vchSet.Append(Method.BuildXML(f_cerl.Action, "")); errorline = 266; GetListAssignTo(fp.outState, vchSet.ToString(), out ListAssignTo); //取得下一關的收件人 f_cerl.ListAssignTo = ListAssignTo; errorline = 269; if (ListAssignTo != "") { errorline = 272; response = PostFormDataToRoute(fc, f_cerl); //Push Task, Send Task mail by AssignTo f_cerl.State = int.Parse(fp.outState.ToString()); db.Entry(f_cerl).State = EntityState.Modified; db.SaveChanges(); errorline = 278; SendMail(fp, f_cerl.fID); errorline = 280; } errorline = 282; } f_cerl.Comment = ""; } catch (Exception ex) { string msg = ex.Message; string newLine = "\r\n"; StringBuilder sb = new StringBuilder(); sb.Append("Issue at line 291: occur error after line " + errorline.ToString() + msg); sb.Append(newLine); sb.Append(f_cerl.ID + " " + f_cerl.State); syserrdb.InitErrorData(Src: fnCheckAndPushTask, content: sb.ToString(), editor: UserId); } return(f_cerl); }