public ActionResult Edit(string memberName, string enggname, string nomer, [Bind(Include = "AuditPlanningMemorandumID,NomerAPM,PreliminaryID,Date_Start,Date_End,Status,ActivityID,TujuanAudit,RuangLingkupAudit,MetodologiAudit,DataDanDokumen,AttachmentMasterID,EntryMeetingDateStart,EntryMeetingDateEnd,WalktroughDateStart,WalktroughDateEnd,FieldWorkDateStart,FieldWorkDateEnd,ExitMeetingDateStart,ExitMeetingDateEnd,LHADateStart,LHADateEnd,PICID,SupervisorID,TeamLeaderID,MemberID,ReviewMasterID,Kesimpulan,ActualEngagement")] AuditPlanningMemorandum auditPlanningMemorandum, IEnumerable <HttpPostedFileBase> files, string[] members, string pic, string supervisor, string leader, string submit, EngagementActivity engga, string activid) { if (ModelState.IsValid) { int i = 0; HttpServerUtilityBase server = Server; List <string> newFilesName = new List <string>(); List <string> paths = new List <string>(); UrlHelper url = Url; List <string> keepImages = new List <string>(); //object imagesTemp = Session["Images"]; var sessionImages = Session["Images"]; if (sessionImages != null) { Array arrKeepImages = (Array)sessionImages; foreach (var arrKeepImage in arrKeepImages) { keepImages.Add(arrKeepImage.ToString()); } bool getFiles = filesTransact.getFiles(auditPlanningMemorandum.NomerAPM.Replace("/", ""), out newFilesName, out paths, url, server); List <string> deletedFiles = paths.Except(keepImages).ToList(); bool deleteFiles = filesTransact.deleteFiles(deletedFiles, server); i = filesTransact.getLastNumberOfFiles(auditPlanningMemorandum.NomerAPM.Replace("/", ""), server); } foreach (var file in files) { if (file != null) { i = i + 1; bool addFile = filesTransact.addFile(auditPlanningMemorandum.NomerAPM.Replace("/", ""), i, file, server); } } Session.Remove("Images"); IQueryable <Preliminary> pre = db.Preliminaries.Where(p => p.NomorPreliminarySurvey.Equals(nomer)); int preId = 0; if (pre.Count() > 0 || pre != null) { preId = pre.Select(p => p.PreliminaryID).FirstOrDefault(); } auditPlanningMemorandum.PreliminaryID = preId; IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid)); int actid = 0; if (act.Count() > 0 || act != null) { actid = act.Select(p => p.ActivityID).FirstOrDefault(); } auditPlanningMemorandum.ActivityID = actid; foreach (var mem in members) { auditPlanningMemorandum.MemberID += mem + ";"; } auditPlanningMemorandum.SupervisorID = supervisor; auditPlanningMemorandum.TeamLeaderID = leader; auditPlanningMemorandum.PICID = pic; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { auditPlanningMemorandum.Status = "Draft"; } else if (submit == "Send Back") { HelperController.GetStatusSendback(db, "Audit Planning Memorandum", auditPlanningMemorandum.Status); } else if (submit == "Approve") { auditPlanningMemorandum.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { auditPlanningMemorandum.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { auditPlanningMemorandum.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = auditPlanningMemorandum.PICID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = auditPlanningMemorandum.SupervisorID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = auditPlanningMemorandum.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = auditPlanningMemorandum.MemberID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } } db.Entry(auditPlanningMemorandum).State = EntityState.Modified; string username = User.Identity.Name; db.Configuration.ProxyCreationEnabled = false; AuditPlanningMemorandum oldData = db.AuditPlanningMemorandums.AsNoTracking().Where(p => p.AuditPlanningMemorandumID.Equals(auditPlanningMemorandum.AuditPlanningMemorandumID)).FirstOrDefault(); auditTransact.CreateAuditTrail("Update", auditPlanningMemorandum.AuditPlanningMemorandumID, "AuditPlanningMemorandum", oldData, auditPlanningMemorandum, username); db.SaveChanges(); TempData["message"] = "Audit Planning Memorandum successfully updated!"; return(RedirectToAction("Index")); } //ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", auditPlanningMemorandum.ActivityID); //ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "Type", auditPlanningMemorandum.PreliminaryID); return(View(auditPlanningMemorandum)); }
public ActionResult Create(string submit, [Bind(Include = "AnnualPlanningID,Date_Start,Date_End,Status,Approval_Status,Tahun,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] AnnualPlanning annualPlanning, string[] member, string supervisor, string pic, string leader, EngagementActivity engagementActivity) { if (ModelState.IsValid) { HttpServerUtilityBase server = Server; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { annualPlanning.Approval_Status = "Draft"; } else if (submit == "Approve") { annualPlanning.Approval_Status = "Approve"; } else if (submit == "Send Back") { annualPlanning.Approval_Status = HelperController.GetStatusSendback(db, "Annual Planning", annualPlanning.Approval_Status); } else if (submit == "Submit For Review By" + user) { annualPlanning.Approval_Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { annualPlanning.Approval_Status = "Pending for Approve by" + user; string activname = db.Activities.Where(p => p.ActivityID.Equals(annualPlanning.ActivityID)).Select(p => p.Name).FirstOrDefault(); string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority); List <string> UserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList(); List <Employee> EmpList = new List <Employee>(); if (UserIds.Count() > 0) { var users = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (UserIds.Contains(p.Id))).ToList(); foreach (var userr in users) { Employee emp = db.Employees.Where(p => p.Email.Equals(userr.Email)).FirstOrDefault(); if (emp != null) { string emailContent = "Dear {0}, <BR/><BR/>There is a Annual Planning that need your approval. Please click on this <a href=\"{2}\" title=\"Annual Planning\">link</a> to show the Annual Planning.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = baseUrl + "/AnnualPlannings/Details/" + annualPlanning.AnnualPlanningID; emailTransact.SentEmailApproval(emp.Email, emp.Name, activname, emailContent, url); } } } } db.AnnualPlannings.Add(annualPlanning); db.SaveChanges(); string username = User.Identity.Name; AnnualPlanning an = new AnnualPlanning(); auditTransact.CreateAuditTrail("Create", annualPlanning.AnnualPlanningID, "AnnualPlanning", an, annualPlanning, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "apl"; rrm.Description = page + annualPlanning.AnnualPlanningID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); TempData["message"] = "Annual Planning successfully created!"; return(RedirectToAction("Index")); } ActivityServices activity = new ActivityServices(); var activities = activity.GetActivity().Where(p => p.Status == "Approve"); IEnumerable <SelectListItem> activityid = activities .Select(d => new SelectListItem { Value = d.ActivityID.ToString(), Text = d.Name }); ViewBag.ActivityID = activityid; ViewBag.membereng = new MultiSelectList(db.Employees, "EmployeeID", "Name"); ViewBag.membereng1 = new MultiSelectList(db.Employees, "EmployeeID", "Name"); return(View(annualPlanning)); }
public ActionResult Create(string nomerapm, string membernull, string enggname, EngagementActivity engga, AuditPlanningMemorandum audit, [Bind(Include = "AuditPlanningMemorandumID,NomerAPM,PreliminaryID,Date_Start,Date_End,Status,ActivityID,TujuanAudit,RuangLingkupAudit,MetodologiAudit,DataDanDokumen,AttachmentMasterID,EntryMeetingDateStart,EntryMeetingDateEnd,WalktroughDateStart,WalktroughDateEnd,FieldWorkDateStart,FieldWorkDateEnd,ExitMeetingDateStart,ExitMeetingDateEnd,LHADateStart,LHADateEnd,PICID,SupervisorID,TeamLeaderID,MemberID,ReviewMasterID,Kesimpulan,ActualEngagement")] AuditPlanningMemorandum auditPlanningMemorandum, IEnumerable <HttpPostedFileBase> files, string submit, string[] members, string supervisor, string pic, string leader, string nomer, string activid) { if (ModelState.IsValid) { HttpServerUtilityBase server = Server; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { auditPlanningMemorandum.Status = "Draft"; } else if (submit == "Send Back") { HelperController.GetStatusSendback(db, "Audit Planning Memorandum", auditPlanningMemorandum.Status); } else if (submit == "Approve") { auditPlanningMemorandum.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { auditPlanningMemorandum.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { auditPlanningMemorandum.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = auditPlanningMemorandum.PICID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = auditPlanningMemorandum.SupervisorID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = auditPlanningMemorandum.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = auditPlanningMemorandum.MemberID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } } foreach (var mem in members) { auditPlanningMemorandum.MemberID += mem + ";"; } IQueryable <Preliminary> prel = db.Preliminaries.Where(p => p.NomorPreliminarySurvey.Equals(nomer)); int preID = 0; if (prel.Count() > 0 || prel != null) { preID = prel.Select(p => p.PreliminaryID).FirstOrDefault(); } auditPlanningMemorandum.PreliminaryID = preID; auditPlanningMemorandum.SupervisorID = supervisor; auditPlanningMemorandum.TeamLeaderID = leader; auditPlanningMemorandum.PICID = pic; IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid)); int actid = 0; if (act.Count() > 0 || act != null) { actid = act.Select(p => p.ActivityID).FirstOrDefault(); } auditPlanningMemorandum.ActivityID = actid; auditPlanningMemorandum.NomerAPM = nomerapm; db.AuditPlanningMemorandums.Add(auditPlanningMemorandum); db.SaveChanges(); int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; bool addFile = filesTransact.addFile(auditPlanningMemorandum.NomerAPM.Replace("/", ""), i, file, server); } } ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "apm"; rrm.Description = page + auditPlanningMemorandum.AuditPlanningMemorandumID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); string username = User.Identity.Name; AuditPlanningMemorandum au = new AuditPlanningMemorandum(); auditTransact.CreateAuditTrail("Create", auditPlanningMemorandum.AuditPlanningMemorandumID, "AuditPlanningMemorandum", au, auditPlanningMemorandum, username); TempData["message"] = "Audit Planning Memorandum successfully created!"; return(RedirectToAction("Index")); } return(View(auditPlanningMemorandum)); }
public ActionResult Create([Bind(Include = "ConsultingSuratPerintahID,NomorSP,ConsultingRequestID,EngagementName,EngagementID,StartDate,EndDate,PicID,SupervisorID,TeamLeaderID,Menimbang,Penutup,MemberID,Remarks")] ConsultingLetterOfCommand consultingletterofcommand, EngagementActivity engagementActivity, string ActivityName, string submit, string[] member, string ConsultingRequest, ConsultingLetterOfCommandDetailDasar Ldasar, ConsultingLetterOfCommandDetailTembusan Ltembusan, ConsultingLetterOfCommandDetailUntuk Luntuk, string[] dasar, string[] tembusan, string[] untuk) { if (ModelState.IsValid) { string username = User.Identity.Name; IQueryable <ConsultingRequest> cr = context.ConsultingRequests.Where(p => p.NoRequest.Equals(ConsultingRequest)); int ConsulId = 0; if (cr.Count() > 0 || cr != null) { ConsulId = cr.Select(p => p.ConsultingRequestID).FirstOrDefault(); } consultingletterofcommand.ConsultingRequestID = ConsulId; foreach (var mb in member) { consultingletterofcommand.MemberID += mb + ";"; } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { consultingletterofcommand.Status = "Draft"; } else if (submit == "Send Back") { consultingletterofcommand.Status = HelperController.GetStatusSendback(context, "Consulting Surat Perintah", consultingletterofcommand.Status); } else if (submit == "Approve") { consultingletterofcommand.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { consultingletterofcommand.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { consultingletterofcommand.Status = "Pending for Approve by" + user; } context.ConsultingLetterOfCommands.Add(consultingletterofcommand); //Engagement Activity //IQueryable<Activity> act = context.Activities.Where(p => p.Name.Equals(ActivityName)); //int ActivityID = 0; //if (act.Count() > 0 || act != null) // ActivityID = act.Select(p => p.ActivityID).FirstOrDefault(); engagementActivity.ActivityStr = ActivityName; engagementActivity.Name = consultingletterofcommand.EngagementName; engagementActivity.PICID = consultingletterofcommand.PicID; engagementActivity.TeamLeaderID = consultingletterofcommand.TeamLeaderID; engagementActivity.SupervisorID = consultingletterofcommand.SupervisorID; engagementActivity.MemberID = consultingletterofcommand.MemberID; context.EngagementActivities.Add(engagementActivity); //Letter of Command Dasar Ldasar.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID; Ldasar.Dasar = null; foreach (var ds in dasar) { Ldasar.Dasar += ds + ";"; } context.ConsultingLetterOfCommandDetailDasars.Add(Ldasar); //Letter of Command Untuk Luntuk.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID; Luntuk.Untuk = null; foreach (var utk in untuk) { Luntuk.Untuk += utk + ";"; } context.ConsultingLetterOfCommandDetailUntuks.Add(Luntuk); //Letter of Command Tembusan Ltembusan.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID; Ltembusan.Tembusan = null; foreach (var tmb in tembusan) { Ltembusan.Tembusan += tmb + ";"; } context.ConsultingLetterOfCommandDetailTembusans.Add(Ltembusan); context.SaveChanges(); //assign engagementID in consulting SP consultingletterofcommand.EngagementID = engagementActivity.EngagementID; context.Entry(consultingletterofcommand).State = EntityState.Modified; //Review Relation Master ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "conleterdetail"; rrm.Description = page + consultingletterofcommand.ConsultingSuratPerintahID; context.ReviewRelationMasters.Add(rrm); context.SaveChanges(); ConsultingLetterOfCommand conletcom = new ConsultingLetterOfCommand(); ConsultingLetterOfCommandDetailDasar conletdasar = new ConsultingLetterOfCommandDetailDasar(); ConsultingLetterOfCommandDetailUntuk conletuntuk = new ConsultingLetterOfCommandDetailUntuk(); ConsultingLetterOfCommandDetailTembusan conlettembusan = new ConsultingLetterOfCommandDetailTembusan(); ConsultingLetterOfCommand conletnew = context.ConsultingLetterOfCommands.Find(consultingletterofcommand.ConsultingSuratPerintahID); auditTransact.CreateAuditTrail("Create", consultingletterofcommand.ConsultingSuratPerintahID, "Consulting Letter Of Command", conletcom, conletnew, username); auditTransact.CreateAuditTrail("Create", Ldasar.ConsultingLetterOfCommandDetailDasarID, "Consulting Letter Of Command Dasar", conletdasar, Ldasar, username); auditTransact.CreateAuditTrail("Create", Luntuk.ConsultingLetterOfCommandDetailUntukID, "Consulting Letter Of Command Untuk", conletuntuk, Luntuk, username); auditTransact.CreateAuditTrail("Create", Ltembusan.ConsultingLetterOfCommandDetailTembusanID, "Consulting Letter Of Command Tembusan", conlettembusan, Ltembusan, username); TempData["message"] = "Consulting Letter Of Command successfully created!"; return(RedirectToAction("Index")); } return(View(consultingletterofcommand)); }
public ActionResult Edit(int?ActivityID, int?EnggaID, EngagementActivity engagementNam, string EngagementName, int?UnActivityID, string submit, [Bind(Include = "PreliminaryID,Type,Status,NomorPreliminarySurvey,Date_Start,Date_End,ReviewMasterID,ActivityID,EmployeeID,EngagementID,PICID,SupervisorID,TeamLeaderID")] Preliminary preliminary, IEnumerable <HttpPostedFileBase> files, string[] member, string[] members) { if (ModelState.IsValid) { int i = 0; HttpServerUtilityBase server = Server; List <string> newFilesName = new List <string>(); List <string> paths = new List <string>(); UrlHelper url = Url; List <string> keepImages = new List <string>(); //object imagesTemp = Session["Images"]; var sessionImages = Session["Images"]; if (sessionImages != null) { Array arrKeepImages = (Array)sessionImages; foreach (var arrKeepImage in arrKeepImages) { keepImages.Add(arrKeepImage.ToString()); } var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool getFiles = filesTransact.getFiles(pre + no, out newFilesName, out paths, url, server); List <string> deletedFiles = paths.Except(keepImages).ToList(); bool deleteFiles = filesTransact.deleteFiles(deletedFiles, server); i = filesTransact.getLastNumberOfFiles(pre + no, server); } foreach (var file in files) { if (file != null) { i = i + 1; var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool addFile = filesTransact.addFile(pre + no, i, file, server); } } Session.Remove("Images"); string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { preliminary.Status = "Draft"; } else if (submit == "Send Back") { preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status); } else if (submit == "Approve") { preliminary.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { preliminary.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { preliminary.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = preliminary.PICID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = preliminary.SupervisorID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = preliminary.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = preliminary.MemberID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } } if (preliminary.Type == "UnPlanned") { preliminary.ActivityID = UnActivityID.Value; preliminary.EngagementID = EnggaID; engagementNam.Name = EngagementName; engagementNam.ActivityID = UnActivityID.Value; engagementNam.EngagementID = EnggaID.Value; engagementNam.Date_Start = engagementNam.Date_Start; engagementNam.Date_End = engagementNam.Date_End; db.Entry(engagementNam).State = EntityState.Modified; } if (member != null) { foreach (var mem in member) { preliminary.EmployeeID += mem + ";"; } } if (members != null) { foreach (var memb in members) { preliminary.MemberID += memb + ";"; } } string username = User.Identity.Name; db.Configuration.ProxyCreationEnabled = false; Preliminary oldData = db.Preliminaries.AsNoTracking().Where(p => p.PreliminaryID.Equals(preliminary.PreliminaryID)).FirstOrDefault(); auditTransact.CreateAuditTrail("Update", preliminary.PreliminaryID, "Preliminary", oldData, preliminary, username); db.Entry(preliminary).State = EntityState.Modified; db.SaveChanges(); TempData["message"] = "Preliminary successfully updated!"; return(RedirectToAction("Index")); } return(View(preliminary)); }
public ActionResult Create(string noprelim, int?ActivityID, string EngagementNameNull, string EngagementName, int?UnActivityID, int?engid, [Bind(Include = "PreliminaryID,Type,Status,NomorPreliminarySurvey,Date_Start,Date_End,EmployeeID,EngagementID,PICID,SupervisorID,TeamLeaderID,MemberID")] Preliminary preliminary, IEnumerable <HttpPostedFileBase> files, string submit, string[] member, string pic, string supervisor, string leader, string[] members) { if (ModelState.IsValid) { if (member != null) { foreach (var mem in member) { preliminary.EmployeeID += mem + ";"; } } preliminary.PICID = pic; preliminary.SupervisorID = supervisor; preliminary.TeamLeaderID = leader; if (members != null) { foreach (var mem in members) { preliminary.MemberID += mem + ";"; } } HttpServerUtilityBase server = Server; int a = 0; if (engid == 0 && a < ActivityID) { EngagementActivity engagement = new EngagementActivity(); engagement.ActivityID = ActivityID.Value; engagement.Name = EngagementNameNull; engagement.Date_Start = null; engagement.Date_End = null; db.EngagementActivities.Add(engagement); db.SaveChanges(); preliminary.ActivityID = ActivityID.Value; preliminary.EngagementID = engagement.EngagementID; preliminary.NomorPreliminarySurvey = noprelim; int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool addFile = filesTransact.addFile(pre + no, i, file, server); } } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { preliminary.Status = "Draft"; } else if (submit == "Send Back") { preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status); } else if (submit == "Approve") { preliminary.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { preliminary.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { preliminary.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = preliminary.PICID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = preliminary.SupervisorID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = preliminary.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = preliminary.MemberID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } } db.Preliminaries.Add(preliminary); db.SaveChanges(); string username = User.Identity.Name; Preliminary pr = new Preliminary(); auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "prelim"; rrm.Description = page + preliminary.PreliminaryID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); } else if (preliminary.Type == "UnPlanned") { EngagementActivity engagement = new EngagementActivity(); engagement.ActivityID = UnActivityID.Value; engagement.Name = EngagementName; engagement.Date_Start = null; engagement.Date_End = null; db.EngagementActivities.Add(engagement); db.SaveChanges(); preliminary.ActivityID = UnActivityID.Value; preliminary.EngagementID = engagement.EngagementID; preliminary.NomorPreliminarySurvey = noprelim; int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool addFile = filesTransact.addFile(pre + no, i, file, server); } } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { preliminary.Status = "Draft"; } else if (submit == "Send Back") { preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status); } else if (submit == "Approve") { preliminary.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { preliminary.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { preliminary.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = preliminary.PICID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = preliminary.SupervisorID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = preliminary.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = preliminary.MemberID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } } db.Preliminaries.Add(preliminary); db.SaveChanges(); string username = User.Identity.Name; Preliminary pr = new Preliminary(); auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "prelim"; rrm.Description = page + preliminary.PreliminaryID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); } else //Type == "Planned" { EngagementActivity engagement = new EngagementActivity(); preliminary.ActivityID = ActivityID.Value; preliminary.EngagementID = engid; preliminary.NomorPreliminarySurvey = noprelim; int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool addFile = filesTransact.addFile(pre + no, i, file, server); } } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { preliminary.Status = "Draft"; } else if (submit == "Send Back") { preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status); } else if (submit == "Approve") { preliminary.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { preliminary.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { preliminary.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = preliminary.PICID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = preliminary.SupervisorID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = preliminary.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = preliminary.MemberID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } } db.Preliminaries.Add(preliminary); db.SaveChanges(); string username = User.Identity.Name; Preliminary pr = new Preliminary(); auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "prelim"; rrm.Description = page + preliminary.PreliminaryID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); } TempData["message"] = "Preliminary successfully created!"; return(RedirectToAction("Index")); } return(View(preliminary)); }
protected virtual void OnNewActivity(EngagementActivity e) { Logger.Debug("Raising a " + e); EventHandler<EngagementActivity> handler = NewActivity; if (handler != null) handler(this, e); }