Exemplo n.º 1
0
        // GET: LetterOfCommands/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LetterOfCommand letterOfCommand = await db.LetterOfCommands.FindAsync(id);

            string letterOfCommandDetailDasar    = db.LetterOfCommandDetailDasars.Find(id).Dasar;
            string letterOfCommandDetailTembusan = db.LetterOfCommandDetailTembusans.Find(id).Tembusan;
            string letterOfCommandDetailUntuk    = db.LetterOfCommandDetailUntuks.Find(id).Untuk;

            ViewBag.Dasar          = letterOfCommandDetailDasar;
            ViewBag.Untuk          = letterOfCommandDetailUntuk;
            ViewBag.Tembusan       = letterOfCommandDetailTembusan;
            ViewBag.NomerAPM       = db.AuditPlanningMemorandums.Find(letterOfCommand.AuditPlanningMemorandumID).NomerAPM;
            ViewBag.MemberName     = letterOfCommand.MemberID;
            ViewBag.SupervisorName = letterOfCommand.SupervisorID;
            ViewBag.TeamLeaderName = letterOfCommand.TeamLeaderID;
            ViewBag.PICIDName      = letterOfCommand.PICID;

            if (letterOfCommand == null)
            {
                return(HttpNotFound());
            }
            return(View(letterOfCommand));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            db.Configuration.ProxyCreationEnabled = false;
            string          username        = User.Identity.Name;
            LetterOfCommand letterOfCommand = await db.LetterOfCommands.FindAsync(id);

            LetterOfCommandDetailDasar letterOfCommandDetailDasar = await db.LetterOfCommandDetailDasars.FindAsync(id);

            LetterOfCommandDetailTembusan letterOfCommandDetailTembusan = await db.LetterOfCommandDetailTembusans.FindAsync(id);

            LetterOfCommandDetailUntuk letterOfCommandDetailUntuk = await db.LetterOfCommandDetailUntuks.FindAsync(id);

            LetterOfCommand               let         = new LetterOfCommand();
            LetterOfCommandDetailDasar    letdasar    = new LetterOfCommandDetailDasar();
            LetterOfCommandDetailUntuk    letuntuk    = new LetterOfCommandDetailUntuk();
            LetterOfCommandDetailTembusan lettembusan = new LetterOfCommandDetailTembusan();

            db.LetterOfCommands.Remove(letterOfCommand);
            db.LetterOfCommandDetailDasars.Remove(letterOfCommandDetailDasar);
            db.LetterOfCommandDetailTembusans.Remove(letterOfCommandDetailTembusan);
            db.LetterOfCommandDetailUntuks.Remove(letterOfCommandDetailUntuk);
            await db.SaveChangesAsync();

            auditTransact.CreateAuditTrail("Delete", id, "LetterOfCommand", letterOfCommand, let, username);
            auditTransact.CreateAuditTrail("Delete", id, "LetterOfCommandDasar", letterOfCommandDetailDasar, letdasar, username);
            auditTransact.CreateAuditTrail("Delete", id, "LetterOfCommandUntuk", letterOfCommandDetailUntuk, letuntuk, username);
            auditTransact.CreateAuditTrail("Delete", id, "LetterOfCommandTembusan", letterOfCommandDetailTembusan, lettembusan, username);
            TempData["message"] = "Letter Of Command successfully deleted!";
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        // GET: LetterOfCommands/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LetterOfCommand letterOfCommand               = db.LetterOfCommands.Find(id);
            string          letterOfCommandDetailDasar    = db.LetterOfCommandDetailDasars.Find(id).Dasar;
            string          letterOfCommandDetailTembusan = db.LetterOfCommandDetailTembusans.Find(id).Tembusan;
            string          letterOfCommandDetailUntuk    = db.LetterOfCommandDetailUntuks.Find(id).Untuk;

            ViewBag.Dasar    = letterOfCommandDetailDasar;
            ViewBag.Untuk    = letterOfCommandDetailUntuk;
            ViewBag.Tembusan = letterOfCommandDetailTembusan;

            if (letterOfCommand == null)
            {
                return(HttpNotFound());
            }

            PreliminaryServices activity = new PreliminaryServices();
            var activities = activity.GetPreliminary().Where(p => p.PreliminaryID == letterOfCommand.AuditPlanningMemorandum.PreliminaryID);

            ViewBag.activid = db.Activities.Where(p => p.ActivityID.Equals(letterOfCommand.ActivityID)).Select(p => p.Name).FirstOrDefault();
            string eng = db.EngagementActivities.Find(letterOfCommand.AuditPlanningMemorandum.Preliminary.EngagementID).Name;

            ViewBag.enggname   = eng;
            ViewBag.nomer      = db.AuditPlanningMemorandums.Find(letterOfCommand.AuditPlanningMemorandumID).NomerAPM;
            ViewBag.member     = letterOfCommand.MemberID;
            ViewBag.supervisor = letterOfCommand.SupervisorID;
            ViewBag.leader     = letterOfCommand.TeamLeaderID;
            ViewBag.pic        = letterOfCommand.PICID;

            return(View(letterOfCommand));
        }
Exemplo n.º 4
0
        public static bool IsMemberSp(int idSP, string uName)
        {
            ePatriaDefault db = new ePatriaDefault();

            LetterOfCommand dbsp = db.LetterOfCommands.Where(d => d.LetterOfCommandID == idSP).FirstOrDefault();

            bool result = dbsp.MemberID.Split(';').Contains(uName);

            db.Dispose();

            return(result);
        }
Exemplo n.º 5
0
        private bool sentSingleEmailSP(string userToSentEmail, LetterOfCommand letterOfCommand)
        {
            string   baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
            Employee emp     = db.Employees.Where(p => p.Name.Equals(userToSentEmail)).FirstOrDefault();

            if (emp != null)
            {
                string emailContent = "Dear {0}, <BR/><BR/>Letter of Command : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Letter of Command\">link</a> to show the Letter of Command.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                string url          = baseUrl + "/LetterOfCommands/Details/" + letterOfCommand.LetterOfCommandID;
                emailTransact.SentEmailApproval(emp.Email, emp.Name, letterOfCommand.NomorSP, emailContent, url);
            }
            return(true);
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Preview(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LetterOfCommand letterOfCommand = await db.LetterOfCommands.FindAsync(id);

            string letterOfCommandDetailDasar    = db.LetterOfCommandDetailDasars.Find(id).Dasar;
            string letterOfCommandDetailTembusan = db.LetterOfCommandDetailTembusans.Find(id).Tembusan;
            string letterOfCommandDetailUntuk    = db.LetterOfCommandDetailUntuks.Find(id).Untuk;

            ViewBag.Dasar          = letterOfCommandDetailDasar;
            ViewBag.Untuk          = letterOfCommandDetailUntuk;
            ViewBag.Tembusan       = letterOfCommandDetailTembusan;
            ViewBag.MemberName     = letterOfCommand.MemberID;
            ViewBag.SupervisorName = letterOfCommand.SupervisorID;
            ViewBag.TeamLeaderName = letterOfCommand.TeamLeaderID;
            ViewBag.PICIDName      = letterOfCommand.PICID;


            List <LetterOfCommandDetailUntuk>    untukList    = new List <LetterOfCommandDetailUntuk>();
            List <LetterOfCommandDetailUntuk>    Untuks       = new List <LetterOfCommandDetailUntuk>();
            List <LetterOfCommandDetailTembusan> tembusanList = new List <LetterOfCommandDetailTembusan>();
            List <LetterOfCommandDetailTembusan> Tembusans    = new List <LetterOfCommandDetailTembusan>();

            Untuks = db.LetterOfCommandDetailUntuks.Where(p => p.LetterOfCommandID.Equals(letterOfCommand.LetterOfCommandID)).ToList();
            foreach (var u in Untuks)
            {
                untukList.Add(u);
            }

            Tembusans = db.LetterOfCommandDetailTembusans.Where(p => p.LetterOfCommandID.Equals(letterOfCommand.LetterOfCommandID)).ToList();
            foreach (var u in Tembusans)
            {
                tembusanList.Add(u);
            }

            if (letterOfCommand == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Untuks    = untukList;
            ViewBag.Tembusans = tembusanList;

            ViewBag.WordDocumentFilename = "SuratPerintah";
            return(View(letterOfCommand));
        }
Exemplo n.º 7
0
        private bool sentEmailSP(LetterOfCommand letterOfCommand, string user)
        {
            string          baseUrl    = Request.Url.GetLeftPart(UriPartial.Authority);
            List <string>   CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList();
            List <Employee> CIAEmpList = new List <Employee>();

            if (CIAUserIds.Count() > 0)
            {
                var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList();
                foreach (var CIAUser in CIAUsers)
                {
                    Employee emp = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault();
                    if (emp != null)
                    {
                        string emailContent = "Dear {0}, <BR/><BR/>Letter of Command : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Letter of Command\">link</a> to show the Letter of Command.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team";
                        string url          = baseUrl + "/LetterOfCommands/Details/" + letterOfCommand.LetterOfCommandID;
                        emailTransact.SentEmailApproval(emp.Email, emp.Name, letterOfCommand.NomorSP, emailContent, url);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 8
0
        public string GetData(string nomer)
        {
            LetterOfCommand letter    = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomer)).FirstOrDefault();
            int             activId   = 0;
            int?            engId     = 0;
            int?            orgId     = 0;
            string          activname = String.Empty;
            string          engname   = String.Empty;
            string          orgname   = String.Empty;

            if (letter != null)
            {
                activId   = letter.ActivityID;
                engId     = letter.AuditPlanningMemorandum.Preliminary.EngagementID;
                orgId     = letter.Activity.DepartementID;
                activname = db.Activities.Find(activId) != null?db.Activities.Find(activId).Name : String.Empty;

                engname = db.EngagementActivities.Find(engId) != null?db.EngagementActivities.Find(engId).Name : String.Empty;

                orgname = db.Organizations.Find(orgId) != null?db.Organizations.Find(orgId).Name : String.Empty;
            }
            return(activname + "," + engname + "," + orgname);
        }
Exemplo n.º 9
0
        public ActionResult Edit([Bind(Include = "ExitMeetingID,ActivityID,EngagementID,Date_Start,Date_End,Status,OrganizationID,LetterOfCommandID,Reviewer1,Reviewer2,StatusTanggapan")] ExitMeeting exitMeeting, string activname, string enggname, string submit, string organame, string nomersp, string period1, string period2)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activname));
                int actID = 0;
                if (act.Count() > 0 || act != null)
                {
                    actID = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                exitMeeting.ActivityID = actID;

                IQueryable <EngagementActivity> eng = db.EngagementActivities.Where(p => p.Name.Equals(enggname));
                int engID = 0;
                if (eng.Count() > 0 || eng != null)
                {
                    engID = eng.Select(p => p.EngagementID).FirstOrDefault();
                }
                exitMeeting.EngagementID = engID;
                exitMeeting.Date_Start   = Convert.ToDateTime(period1);
                exitMeeting.Date_End     = Convert.ToDateTime(period2);

                IQueryable <Organization> org = db.Organizations.Where(p => p.Name.Equals(organame));
                int orgID = 0;
                if (act.Count() > 0 || act != null)
                {
                    orgID = org.Select(p => p.OrganizationID).FirstOrDefault();
                }
                exitMeeting.OrganizationID = orgID;

                IQueryable <LetterOfCommand> letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp));
                int letterID = 0;
                if (letter.Count() > 0 || letter != null)
                {
                    letterID = letter.Select(p => p.LetterOfCommandID).FirstOrDefault();
                }
                exitMeeting.LetterOfCommandID = letterID;
                LetterOfCommand sp = db.LetterOfCommands.Find(exitMeeting.LetterOfCommandID);

                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    exitMeeting.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    exitMeeting.Status = HelperController.GetStatusSendback(db, "Exit Meeting", exitMeeting.Status);
                }
                else if (submit == "Approve")
                {
                    exitMeeting.Status          = "Approve";
                    exitMeeting.StatusTanggapan = "Closed";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    exitMeeting.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    exitMeeting.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = sp.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = sp.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = sp.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = sp.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                }
                ExitMeeting oldData = db.ExitMeetings.AsNoTracking().Where(p => p.ExitMeetingID.Equals(exitMeeting.ExitMeetingID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", exitMeeting.ExitMeetingID, "Exit Meeting", oldData, exitMeeting, username);
                db.Entry(exitMeeting).State = EntityState.Modified;
                db.SaveChanges();
                TempData["message"] = "Exit Meeting successfully updated!";
                return(RedirectToAction("Index"));
            }
            ViewBag.nomersp   = db.LetterOfCommands.Where(p => p.LetterOfCommandID.Equals(exitMeeting.ExitMeetingID)).Select(p => p.NomorSP).FirstOrDefault();
            ViewBag.activname = db.Activities.Where(p => p.ActivityID.Equals(exitMeeting.ActivityID)).Select(p => p.Name).FirstOrDefault();
            ViewBag.enggname  = db.EngagementActivities.Where(p => p.EngagementID.Equals(exitMeeting.EngagementID)).Select(p => p.Name).FirstOrDefault();
            ViewBag.organame  = db.Organizations.Where(p => p.OrganizationID.Equals(exitMeeting.OrganizationID)).Select(p => p.Name).FirstOrDefault();
            return(View(exitMeeting));
        }
Exemplo n.º 10
0
        public ActionResult Create([Bind(Include = "ExitMeetingID,ActivityID,EngagementID,Date_Start,Date_End,Status,OrganizationID,LetterOfCommandID,Reviewer1,Reviewer2")] ExitMeeting exitMeeting, string activname, string enggname, string submit, string organame, string nomersp, string period1, string period2)
        {
            if (ModelState.IsValid)
            {
                string username           = User.Identity.Name;
                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activname));
                int actID = 0;
                if (act.Count() > 0 || act != null)
                {
                    actID = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                exitMeeting.ActivityID = actID;

                IQueryable <EngagementActivity> eng = db.EngagementActivities.Where(p => p.Name.Equals(enggname));
                int engID = 0;
                if (eng.Count() > 0 || eng != null)
                {
                    engID = eng.Select(p => p.EngagementID).FirstOrDefault();
                }
                exitMeeting.EngagementID = engID;
                exitMeeting.Date_Start   = Convert.ToDateTime(period1);
                exitMeeting.Date_End     = Convert.ToDateTime(period2);

                IQueryable <Organization> org = db.Organizations.Where(p => p.Name.Equals(organame));
                int orgID = 0;
                if (act.Count() > 0 || act != null)
                {
                    orgID = org.Select(p => p.OrganizationID).FirstOrDefault();
                }
                exitMeeting.OrganizationID = orgID;

                IQueryable <LetterOfCommand> letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp));
                int letterID = 0;
                if (letter.Count() > 0 || letter != null)
                {
                    letterID = letter.Select(p => p.LetterOfCommandID).FirstOrDefault();
                }
                exitMeeting.LetterOfCommandID = letterID;
                LetterOfCommand sp   = db.LetterOfCommands.Find(exitMeeting.LetterOfCommandID);
                string          user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    exitMeeting.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    exitMeeting.Status = HelperController.GetStatusSendback(db, "Exit Meeting", exitMeeting.Status);
                }
                else if (submit == "Approve")
                {
                    exitMeeting.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    exitMeeting.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    exitMeeting.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = sp.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = sp.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = sp.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = sp.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailEM(userToSentEmail, exitMeeting);
                        }
                        else
                        {
                            sentEmailEM(exitMeeting, user.Trim());
                        }
                    }
                }
                exitMeeting.StatusTanggapan = "On Progress";
                db.ExitMeetings.Add(exitMeeting);
                db.SaveChanges();
                ExitMeeting exitmeet = new ExitMeeting();
                auditTransact.CreateAuditTrail("Create", exitMeeting.ExitMeetingID, "Exit Meeting", exitmeet, exitMeeting, username);

                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "exitmeet";
                rrm.Description = page + exitMeeting.ExitMeetingID;
                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();

                TempData["message"] = "Exit Meeting successfully created!";
                return(RedirectToAction("Index"));
            }

            //LetterOfCommand letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp)).FirstOrDefault();
            //var activId = letter.ActivityID;
            //var engId = letter.Preliminary.EngagementID;
            //var orgId = letter.Activity.DepartementID;
            //string activnam = db.Activities.Find(activId).Name;
            //string engname = db.EngagementActivities.Find(engId).Name;
            //string orgname = db.Organizations.Find(orgId).Name;
            //var data =  activnam + "," + engname + "," + orgname;
            return(View(exitMeeting));
        }
Exemplo n.º 11
0
        public async Task <ActionResult> Update(string submit, [Bind(Include = "LetterOfCommandID,NomorSP,Status,Remarks,AssuranceType,Date_Start,Date_End,Menimbang,Penutup,AuditPlanningMemorandumID,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] LetterOfCommand letterOfCommand)
        {
            if (ModelState.IsValid)
            {
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    letterOfCommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    letterOfCommand.Status = HelperController.GetStatusSendback(db, "Surat Perintah", letterOfCommand.Status);
                }
                else if (submit == "Approve")
                {
                    letterOfCommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    letterOfCommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    letterOfCommand.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = letterOfCommand.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = letterOfCommand.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = letterOfCommand.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = letterOfCommand.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                }

                string username = User.Identity.Name;
                db.Configuration.ProxyCreationEnabled = false;
                LetterOfCommand oldData = db.LetterOfCommands.AsNoTracking().Where(p => p.LetterOfCommandID.Equals(letterOfCommand.LetterOfCommandID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", letterOfCommand.LetterOfCommandID, "LetterOfCommand", oldData, letterOfCommand, username);
                db.Entry(letterOfCommand).State = EntityState.Modified;
                await db.SaveChangesAsync();

                TempData["message"] = "Letter Of Command successfully updated!";
                return(RedirectToAction("Index"));
            }
            ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "Type", letterOfCommand.PreliminaryID);
            return(View(letterOfCommand));
        }
Exemplo n.º 12
0
        public async Task <ActionResult> Edit(string submit, string Status, string[] Dasar, string[] Untuk, string[] Tembusan, string activid, string memberName, string[] member, string pic, string supervisor, string leader, string nomer, [Bind(Include = "LetterOfCommandID,NomorSP,Status,Remarks,AssuranceType,Date_Start,Date_End,Menimbang,Penutup,AuditPlanningMemorandumID,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] LetterOfCommand letterOfCommand)
        {
            if (ModelState.IsValid)
            {
                letterOfCommand.Status = Status;

                IQueryable <AuditPlanningMemorandum> apm = db.AuditPlanningMemorandums.Where(p => p.NomerAPM.Equals(nomer));
                int apmId = 0;
                if (apm.Count() > 0 || apm != null)
                {
                    apmId = apm.Select(p => p.AuditPlanningMemorandumID).FirstOrDefault();
                    letterOfCommand.AuditPlanningMemorandumID = apmId;
                }
                letterOfCommand.SupervisorID = supervisor;
                letterOfCommand.TeamLeaderID = leader;
                letterOfCommand.PICID        = pic;
                if (member != null)
                {
                    foreach (var mb in member)
                    {
                        letterOfCommand.MemberID += mb + ";";
                    }
                }
                else
                {
                    letterOfCommand.MemberID += ";";
                }
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    letterOfCommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    letterOfCommand.Status = HelperController.GetStatusSendback(db, "Surat Perintah", letterOfCommand.Status);
                }
                else if (submit == "Approve")
                {
                    letterOfCommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    letterOfCommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    letterOfCommand.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = letterOfCommand.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = letterOfCommand.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = letterOfCommand.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = letterOfCommand.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                }

                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid));
                int activ = 0;
                if (act.Count() > 0 || act != null)
                {
                    activ = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                letterOfCommand.ActivityID = activ;

                db.Configuration.ProxyCreationEnabled = false;
                LetterOfCommandDetailDasar    letterOfCommandDetailDasar    = db.LetterOfCommandDetailDasars.AsNoTracking().Where(p => p.LetterOfCommandID == letterOfCommand.LetterOfCommandID).FirstOrDefault();
                LetterOfCommandDetailUntuk    letterOfCommandDetailUntuk    = db.LetterOfCommandDetailUntuks.AsNoTracking().Where(p => p.LetterOfCommandID == letterOfCommand.LetterOfCommandID).FirstOrDefault();
                LetterOfCommandDetailTembusan letterOfCommandDetailTembusan = db.LetterOfCommandDetailTembusans.AsNoTracking().Where(p => p.LetterOfCommandID == letterOfCommand.LetterOfCommandID).FirstOrDefault();
                letterOfCommandDetailDasar.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailDasar.Dasar             = null;
                if (Dasar != null)
                {
                    foreach (var ds in Dasar)
                    {
                        letterOfCommandDetailDasar.Dasar += ds + ";";
                    }
                }
                else
                {
                    letterOfCommandDetailDasar.Dasar = ";";
                }

                letterOfCommandDetailUntuk.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailUntuk.Untuk             = null;
                if (Untuk != null)
                {
                    foreach (var uk in Untuk)
                    {
                        letterOfCommandDetailUntuk.Untuk += uk + ";";
                    }
                }
                else
                {
                    letterOfCommandDetailUntuk.Untuk = ";";
                }

                letterOfCommandDetailTembusan.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailTembusan.Tembusan          = null;
                if (Tembusan != null)
                {
                    foreach (var ts in Tembusan)
                    {
                        letterOfCommandDetailTembusan.Tembusan += ts + ";";
                    }
                }
                else
                {
                    letterOfCommandDetailTembusan.Tembusan = ";";
                }

                string                        username        = User.Identity.Name;
                LetterOfCommand               oldData         = db.LetterOfCommands.AsNoTracking().Where(p => p.LetterOfCommandID.Equals(letterOfCommand.LetterOfCommandID)).FirstOrDefault();
                LetterOfCommandDetailDasar    oldDataDasar    = db.LetterOfCommandDetailDasars.AsNoTracking().Where(p => p.ID.Equals(letterOfCommandDetailDasar.ID)).FirstOrDefault();
                LetterOfCommandDetailUntuk    oldDataUntuk    = db.LetterOfCommandDetailUntuks.AsNoTracking().Where(p => p.ID.Equals(letterOfCommandDetailUntuk.ID)).FirstOrDefault();
                LetterOfCommandDetailTembusan oldDataTembusan = db.LetterOfCommandDetailTembusans.AsNoTracking().Where(p => p.ID.Equals(letterOfCommandDetailTembusan.ID)).FirstOrDefault();
                auditTransact.CreateAuditTrail("Update", letterOfCommand.LetterOfCommandID, "LetterOfCommand", oldData, letterOfCommand, username);
                auditTransact.CreateAuditTrail("Update", letterOfCommandDetailDasar.ID, "LetterOfCommandDasar", oldDataDasar, letterOfCommandDetailDasar, username);
                auditTransact.CreateAuditTrail("Update", letterOfCommandDetailUntuk.ID, "LetterOfCommandUntuk", oldDataUntuk, letterOfCommandDetailUntuk, username);
                auditTransact.CreateAuditTrail("Update", letterOfCommandDetailTembusan.ID, "LetterOfCommandTembusan", oldDataTembusan, letterOfCommandDetailTembusan, username);

                db.Entry(letterOfCommandDetailDasar).State    = EntityState.Modified;
                db.Entry(letterOfCommandDetailUntuk).State    = EntityState.Modified;
                db.Entry(letterOfCommandDetailTembusan).State = EntityState.Modified;
                db.Entry(letterOfCommand).State = EntityState.Modified;
                await db.SaveChangesAsync();

                TempData["message"] = "Letter Of Command successfully updated!";
                return(RedirectToAction("Index"));
            }
            ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "Type", letterOfCommand.PreliminaryID);
            return(View(letterOfCommand));
        }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "LetterOfCommandID,NomorSP,Status,Remarks,AssuranceType,Date_Start,Date_End,Menimbang,Penutup,AuditPlanningMemorandumID,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] LetterOfCommand letterOfCommand,
                                   LetterOfCommandDetailDasar letterOfCommandDetailDasar, LetterOfCommandDetailUntuk letterOfCommandDetailUntuk,
                                   LetterOfCommandDetailTembusan letterOfCommandDetailTembusan, string letterno, string membernull,
                                   string activid, string[] members, string pic, string supervisor, string leader, string nomer,
                                   string submit, string[] dasar, string[] untuk, string[] tembusan)
        {
            if (ModelState.IsValid)
            {
                string username = User.Identity.Name;

                HttpServerUtilityBase server = Server;
                string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty;
                if (submit == "Save")
                {
                    letterOfCommand.Status = "Draft";
                }
                else if (submit == "Send Back")
                {
                    letterOfCommand.Status = HelperController.GetStatusSendback(db, "Surat Perintah", letterOfCommand.Status);
                }
                else if (submit == "Approve")
                {
                    letterOfCommand.Status = "Approve";
                }
                else if (submit == "Submit For Review By" + user)
                {
                    letterOfCommand.Status = "Pending for Review by" + user;
                }
                else if (submit == "Submit For Approve By" + user)
                {
                    letterOfCommand.Status = "Pending for Approve by" + user;
                    string userToSentEmail = String.Empty;
                    if (user.Trim() == "CIA")
                    {
                        userToSentEmail = letterOfCommand.PICID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Pengawas")
                    {
                        userToSentEmail = letterOfCommand.SupervisorID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Ketua Tim")
                    {
                        userToSentEmail = letterOfCommand.TeamLeaderID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                    else if (user.Trim() == "Member")
                    {
                        userToSentEmail = letterOfCommand.MemberID;
                        if (userToSentEmail != null)
                        {
                            sentSingleEmailSP(userToSentEmail, letterOfCommand);
                        }
                        else
                        {
                            sentEmailSP(letterOfCommand, user.Trim());
                        }
                    }
                }

                IQueryable <AuditPlanningMemorandum> apm = db.AuditPlanningMemorandums.Where(p => p.NomerAPM.Equals(nomer));
                int apmId = 0;
                if (apm.Count() > 0 || apm != null)
                {
                    apmId = apm.Select(p => p.AuditPlanningMemorandumID).FirstOrDefault();
                    letterOfCommand.AuditPlanningMemorandumID = apmId;
                }
                letterOfCommand.SupervisorID = supervisor;
                letterOfCommand.TeamLeaderID = leader;
                letterOfCommand.PICID        = pic;


                IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid));
                int activ = 0;
                if (act.Count() > 0 || act != null)
                {
                    activ = act.Select(p => p.ActivityID).FirstOrDefault();
                }
                letterOfCommand.ActivityID = activ;

                string   tahun1    = letterOfCommand.Date_Start.ToShortDateString().Split('/')[2] + ";";
                string   tahun2    = letterOfCommand.Date_End.ToShortDateString().Split('/')[2] + ";";
                Activity actLetter = db.Activities.Find(activ);
                if (actLetter.Tahun != null)
                {
                    if (tahun1 != tahun2)
                    {
                        if (!actLetter.Tahun.Contains(tahun1))
                        {
                            actLetter.Tahun += tahun1;
                        }
                        if (!actLetter.Tahun.Contains(tahun2))
                        {
                            actLetter.Tahun += tahun2;
                        }
                    }
                    else
                    {
                        if (!actLetter.Tahun.Contains(tahun1))
                        {
                            actLetter.Tahun += tahun1;
                        }
                    }
                }
                else
                {
                    if (tahun1 != tahun2)
                    {
                        actLetter.Tahun = tahun1 + tahun2;
                    }
                    else
                    {
                        actLetter.Tahun = tahun1;
                    }
                }
                db.Entry(actLetter).State = EntityState.Modified;
                letterOfCommand.NomorSP   = letterno;
                foreach (var mb in members)
                {
                    letterOfCommand.MemberID += mb + ";";
                }
                letterOfCommandDetailDasar.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailDasar.Dasar             = null;
                foreach (var ds in dasar)
                {
                    letterOfCommandDetailDasar.Dasar += ds + ";";
                }
                letterOfCommandDetailUntuk.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailUntuk.Untuk             = null;
                foreach (var utk in untuk)
                {
                    letterOfCommandDetailUntuk.Untuk += utk + ";";
                }
                letterOfCommandDetailTembusan.LetterOfCommandID = letterOfCommand.LetterOfCommandID;
                letterOfCommandDetailTembusan.Tembusan          = null;
                foreach (var tmb in tembusan)
                {
                    letterOfCommandDetailTembusan.Tembusan += tmb + ";";
                }
                db.LetterOfCommandDetailDasars.Add(letterOfCommandDetailDasar);
                db.LetterOfCommandDetailTembusans.Add(letterOfCommandDetailTembusan);
                db.LetterOfCommandDetailUntuks.Add(letterOfCommandDetailUntuk);
                db.LetterOfCommands.Add(letterOfCommand);
                db.SaveChanges();
                LetterOfCommand               let         = new LetterOfCommand();
                LetterOfCommandDetailDasar    letDasar    = new LetterOfCommandDetailDasar();
                LetterOfCommandDetailUntuk    letUntuk    = new LetterOfCommandDetailUntuk();
                LetterOfCommandDetailTembusan letTembusan = new LetterOfCommandDetailTembusan();
                auditTransact.CreateAuditTrail("Create", letterOfCommand.LetterOfCommandID, "LetterOfCommand", let, letterOfCommand, username);
                auditTransact.CreateAuditTrail("Create", letterOfCommandDetailDasar.ID, "LetterOfCommandDetailDasar", letDasar, letterOfCommandDetailDasar, username);
                auditTransact.CreateAuditTrail("Create", letterOfCommandDetailUntuk.ID, "LetterOfCommandDetailUntuk", letUntuk, letterOfCommandDetailUntuk, username);
                auditTransact.CreateAuditTrail("Create", letterOfCommandDetailTembusan.ID, "LetterOfCommandDetailTembusan", letTembusan, letterOfCommandDetailTembusan, username);
                ReviewRelationMaster rrm = new ReviewRelationMaster();
                string page = "letter";
                rrm.Description = page + letterOfCommand.LetterOfCommandID;

                db.ReviewRelationMasters.Add(rrm);
                db.SaveChanges();
                TempData["message"] = "Letter Of Command successfully created!";
                return(RedirectToAction("Index"));
            }

            ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "NomorPreliminarySurvey", letterOfCommand.PreliminaryID);
            return(View(letterOfCommand));
        }
Exemplo n.º 14
0
        public string getNewNumber(string type)
        {
            ePatriaDefault db       = new ePatriaDefault();
            string         result   = String.Empty;
            int            length   = 4;
            int            no       = 1;
            string         newNo    = string.Empty;
            int            year     = DateTime.Now.Year;
            bool           noExist  = false;
            string         formatNo = string.Empty;

            if (type == "SP")
            {
                LetterOfCommand sp = db.LetterOfCommands.OrderByDescending(p => p.LetterOfCommandID).FirstOrDefault();
                if (sp != null)
                {
                    noExist = db.LetterOfCommands.Any(p => p.NomorSP.Contains("/PPN030/Prin/"));
                    if (noExist)
                    {
                        no = Convert.ToInt32(sp.NomorSP.Split('/')[0]) + 1;
                    }
                }
                newNo  = no.ToString().PadLeft(length, '0');
                result = newNo + "/PPN030/Prin/" + year;
            }
            else if (type == "Reporting")
            {
                Reporting rep = db.Reportings.OrderByDescending(p => p.ReportingID).FirstOrDefault();
                if (rep != null)
                {
                    noExist = db.Reportings.Any(p => p.NomorLaporan.Contains("/PPN030/Lap/"));
                    if (noExist)
                    {
                        no = Convert.ToInt32(rep.NomorLaporan.Split('/')[0]) + 1;
                    }
                }
                newNo  = no.ToString().PadLeft(length, '0');
                result = newNo + "/PPN030/Lap/" + year;
            }
            else if (type == "CSP")
            {
                ConsultingLetterOfCommand csp = db.ConsultingLetterOfCommands.OrderByDescending(p => p.ConsultingSuratPerintahID).FirstOrDefault();
                if (csp != null)
                {
                    noExist = db.ConsultingLetterOfCommands.Any(p => p.NomorSP.Contains("/PPN030/CPrin/"));
                    if (noExist)
                    {
                        no = Convert.ToInt32(csp.NomorSP.Split('/')[0]) + 1;
                    }
                }
                newNo  = no.ToString().PadLeft(length, '0');
                result = newNo + "/PPN030/CPrin/" + year;
            }
            else if (type == "CReporting")
            {
                ConsultingReporting crep = db.ConsultingReportings.OrderByDescending(p => p.ConsultingReportingID).FirstOrDefault();
                if (crep != null)
                {
                    noExist = db.ConsultingReportings.Any(p => p.NoLaporan.Contains("/PPN030/CLap/"));
                    if (noExist)
                    {
                        no = Convert.ToInt32(crep.NoLaporan.Split('/')[0]) + 1;
                    }
                }
                newNo  = no.ToString().PadLeft(length, '0');
                result = newNo + "/PPN030/CLap/" + year;
            }
            else if (type == "CRequest")
            {
                ConsultingRequest creq = db.ConsultingRequests.OrderByDescending(p => p.ConsultingRequestID).FirstOrDefault();
                if (creq != null)
                {
                    noExist = db.ConsultingRequests.Any(p => p.NoRequest.Contains("/PPN030/"));
                    if (noExist)
                    {
                        no = Convert.ToInt32(creq.NoRequest.Split('/')[0]) + 1;
                    }
                }
                newNo  = no.ToString().PadLeft(length, '0');
                result = newNo + "/PPN030/" + year;
            }
            return(result);
        }