コード例 #1
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         using (DBuserSignupLoginEntities3 db = new DBuserSignupLoginEntities3())
         {
             Task_report task_Report = db.Task_report.Where(x => x.id == id).FirstOrDefault();
             task_Report.Active = 0;
             //db.Task_report.Remove(task_Report);
             db.SaveChanges();
         }
         TempData["message"] = "Task Report has been deleted successfully!";
         return(RedirectToAction("Delete", "Task_Report"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #2
0
        public ActionResult Index(Task_report task_Report, Team_names team)
        {
            if (task_Report.risk == "Help")
            {
                task_Report.risk = "1";
            }
            else if (task_Report.risk == null)
            {
                task_Report.risk = "0";
            }
            if (String.IsNullOrEmpty(task_Report.emp_id.ToString()) || String.IsNullOrEmpty(task_Report.team_name) || String.IsNullOrEmpty(task_Report.summary))
            {
                //ViewBag.Notification = "Id, role and password are required";
                return(View());
            }
            else if (String.IsNullOrEmpty(task_Report.start_date) || String.IsNullOrEmpty(task_Report.end_date))
            {
                //ViewBag.Notification = "start date and end date are required";
                return(View());
            }
            else if (db.Employees.All(x => x.id != task_Report.emp_id))
            {
                ViewBag.Notification = "This employee id " + task_Report.emp_id + " does not exists";
                return(View());
            }
            else if (Convert.ToInt32(Session["IdUsSS1"]) != task_Report.emp_id)
            {
                ViewBag.Notification = "Give your employee id";
                return(View());
            }
            else if (db.Team_names.All(x => x.Team_name != task_Report.team_name))
            {
                ViewBag.Notification = "The team name does not exists";
                return(View());
            }
            else if (task_Report.risk.ToString() == "1")
            {
                if (String.IsNullOrEmpty(task_Report.risk_details) || String.IsNullOrEmpty(task_Report.risk_resolution))
                {
                    ViewBag.Notification = "Risk details/risk resolution are required when risk is there";
                    return(View());
                }
                else
                {
                    DateTime startD           = DateTime.Parse(task_Report.start_date);
                    DateTime endD             = DateTime.Parse(task_Report.end_date);
                    double   calcBusinessDays = 1 + ((endD - startD).TotalDays * 5 - (startD.DayOfWeek - endD.DayOfWeek) * 2) / 7;

                    if (endD.DayOfWeek == DayOfWeek.Saturday)
                    {
                        calcBusinessDays--;
                    }
                    if (startD.DayOfWeek == DayOfWeek.Sunday)
                    {
                        calcBusinessDays--;
                    }
                    task_Report.task_duration = (int)calcBusinessDays;
                    task_Report.Active        = 1;
                    ViewData["msg"]           = task_Report;
                    db.Task_report.Add(task_Report);
                    db.SaveChanges();
                    //ViewBag.Notification1 = "The task report has been successfully created!";
                    TempData["message"] = "Task Report has been created successfully!";
                    return(RedirectToAction("Index", "Task_Report"));
                }
            }
            else
            {
                DateTime startD           = DateTime.Parse(task_Report.start_date);
                DateTime endD             = DateTime.Parse(task_Report.end_date);
                double   calcBusinessDays = 1 + ((endD - startD).TotalDays * 5 - (startD.DayOfWeek - endD.DayOfWeek) * 2) / 7;

                if (endD.DayOfWeek == DayOfWeek.Saturday)
                {
                    calcBusinessDays--;
                }
                if (startD.DayOfWeek == DayOfWeek.Sunday)
                {
                    calcBusinessDays--;
                }
                task_Report.task_duration = (int)calcBusinessDays;
                task_Report.Active        = 1;
                ViewData["msg"]           = task_Report;
                db.Task_report.Add(task_Report);
                db.SaveChanges();
                //ViewBag.Notification1 = "The task report has been successfully created!";
                TempData["message"] = "Task Report has been created successfully!";
                return(RedirectToAction("Index", "Task_Report"));
            }
            //return View();
        }
コード例 #3
0
        public ActionResult Edit(int id, Task_report task_Report, Team_names team)
        {
            try
            {
                if (task_Report.risk == "Help")
                {
                    task_Report.risk = "1";
                }
                else if (task_Report.risk == null)
                {
                    task_Report.risk = "0";
                }
                if (String.IsNullOrEmpty(task_Report.emp_id.ToString()) || String.IsNullOrEmpty(task_Report.start_date) || String.IsNullOrEmpty(task_Report.end_date) || String.IsNullOrEmpty(task_Report.team_name) || String.IsNullOrEmpty(task_Report.summary) || String.IsNullOrEmpty(task_Report.task_duration.ToString()))
                {
                    ViewBag.Notification = "Id/start date/end date/summary/team name are required";
                    return(View());
                }
                else if (String.IsNullOrEmpty(task_Report.start_date) || String.IsNullOrEmpty(task_Report.end_date))
                {
                    ViewBag.Notification = "start date and end date are required";
                    return(View());
                }
                else if (db.Employees.All(x => x.id != task_Report.emp_id))
                {
                    ViewBag.Notification = "This employee id does not exists";
                    return(View());
                }
                else if (Convert.ToInt32(Session["IdUsSS1"]) != task_Report.emp_id)
                {
                    ViewBag.Notification = "employee id can't be changed";
                    return(View());
                }
                else if (db.Team_names.All(x => x.Team_name != task_Report.team_name))
                {
                    ViewBag.Notification = "The team name does not exists";
                    return(View());
                }
                else if (task_Report.risk.ToString() == "1")
                {
                    if (String.IsNullOrEmpty(task_Report.risk_details) || String.IsNullOrEmpty(task_Report.risk_resolution))
                    {
                        ViewBag.Notification = "Risk details and risk resolution are required";
                    }
                    else
                    {
                        DateTime startD           = DateTime.Parse(task_Report.start_date);
                        DateTime endD             = DateTime.Parse(task_Report.end_date);
                        double   calcBusinessDays = 1 + ((endD - startD).TotalDays * 5 - (startD.DayOfWeek - endD.DayOfWeek) * 2) / 7;

                        if (endD.DayOfWeek == DayOfWeek.Saturday)
                        {
                            calcBusinessDays--;
                        }
                        if (startD.DayOfWeek == DayOfWeek.Sunday)
                        {
                            calcBusinessDays--;
                        }
                        task_Report.task_duration = (int)calcBusinessDays;
                        task_Report.Active        = 1;
                        ViewData["msg"]           = task_Report;
                        db.Task_report.Add(task_Report);
                        db.SaveChanges();
                        //ViewBag.Notification1 = "The task report has been successfully created!";
                        TempData["message"] = "Task Report has been updated successfully!";
                        return(RedirectToAction("Edit", "Task_Report"));
                    }
                    return(View());
                }
                else
                {
                    DateTime startD           = DateTime.Parse(task_Report.start_date);
                    DateTime endD             = DateTime.Parse(task_Report.end_date);
                    double   calcBusinessDays = 1 + ((endD - startD).TotalDays * 5 - (startD.DayOfWeek - endD.DayOfWeek) * 2) / 7;

                    if (endD.DayOfWeek == DayOfWeek.Saturday)
                    {
                        calcBusinessDays--;
                    }
                    if (startD.DayOfWeek == DayOfWeek.Sunday)
                    {
                        calcBusinessDays--;
                    }
                    task_Report.task_duration   = (int)calcBusinessDays;
                    task_Report.Active          = 1;
                    db.Entry(task_Report).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["message"] = "Task Report has been updated successfully!";
                    return(RedirectToAction("Edit", "Task_Report"));
                }
            }
            catch
            {
                return(View());
            }
        }