using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Web.Mvc;

using TimeControlReportEnhancements.Models;

namespace TimeControlReportEnhancements.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
           
            return View();
        }

       
        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]      
        public ActionResult GetAllEmployees([DataSourceRequest] DataSourceRequest request)
        {
            DataTable Oracleresult = new DataTable();
            DataTable SQLresult = new DataTable();
            DataTable EmpResult = new DataTable();
            List<TimeControlGrid> GridList = new List<TimeControlGrid>();


            //int count = 25;
            //for (int i = 0; i < 50; i++)
            //{
                int i = 1;
                GridList.Add(new TimeControlGrid()
                    {
                        EmpNumber = Convert.ToInt32(i),
                        EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                        Dept = new Department() { DeptName = "dept" + i.ToString() },
                        ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                        ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                        ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                        CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                        Jan = Convert.ToInt32(i),
                        Feb = Convert.ToInt32(i),
                        Mar = Convert.ToInt32(i),
                        Apr = Convert.ToInt32(i),
                        May = Convert.ToInt32(i),
                        Jun = Convert.ToInt32(i),
                        Jul = Convert.ToInt32(i),
                        Aug = Convert.ToInt32(i),
                        Sep = Convert.ToInt32(i),
                        Oct = Convert.ToInt32(i),
                        Nov = Convert.ToInt32(i),
                        Dec = Convert.ToInt32(i),
                        HoursYTD = (Convert.ToInt32(i) * 12)
                    });
             i = 3;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });
            i = 5;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });
            i = 7;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });
            i = 9;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });
            i = 2;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });
            i = 4;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });
            i = 6;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });
            i = 8;
            GridList.Add(new TimeControlGrid()
            {
                EmpNumber = Convert.ToInt32(i),
                EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                Dept = new Department() { DeptName = "dept" + i.ToString() },
                ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode = i.ToString() },
                ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode = i.ToString() },
                CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                Jan = Convert.ToInt32(i),
                Feb = Convert.ToInt32(i),
                Mar = Convert.ToInt32(i),
                Apr = Convert.ToInt32(i),
                May = Convert.ToInt32(i),
                Jun = Convert.ToInt32(i),
                Jul = Convert.ToInt32(i),
                Aug = Convert.ToInt32(i),
                Sep = Convert.ToInt32(i),
                Oct = Convert.ToInt32(i),
                Nov = Convert.ToInt32(i),
                Dec = Convert.ToInt32(i),
                HoursYTD = (Convert.ToInt32(i) * 12)
            });

            //}
            return Json(GridList.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }
       

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult EmployeeDetailsUpdate([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<TimeControlGrid> Employees)
        {

            DataTable Oracleresult = new DataTable();
            DataTable SQLresult = new DataTable();
            DataTable EmpResult = new DataTable();
            List<TimeControlGrid> GridList = new List<TimeControlGrid>();


            //int count = 25;
            for (int i = 0; i < 50; i++)
            {
                GridList.Add(new TimeControlGrid()
                {
                    EmpNumber = Convert.ToInt32(i),
                    EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                    Dept = new Department() { DeptName = "dept" + i.ToString() },
                    ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode =i.ToString() },
                    ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                    ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode =i.ToString() },
                    CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                    Jan = Convert.ToInt32(i),
                    Feb = Convert.ToInt32(i),
                    Mar = Convert.ToInt32(i),
                    Apr = Convert.ToInt32(i),
                    May = Convert.ToInt32(i),
                    Jun = Convert.ToInt32(i),
                    Jul = Convert.ToInt32(i),
                    Aug = Convert.ToInt32(i),
                    Sep = Convert.ToInt32(i),
                    Oct = Convert.ToInt32(i),
                    Nov = Convert.ToInt32(i),
                    Dec = Convert.ToInt32(i),
                    HoursYTD = (Convert.ToInt32(i) * 12)
                });

            }

            return Json(GridList.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }

       
        public ActionResult HoursByProject()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());           

            return View();
        }
        

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]

        public ActionResult CreateEmployeeDetails([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<TimeControlGrid> Employees)
        {
            DataTable Oracleresult = new DataTable();
            DataTable SQLresult = new DataTable();
            DataTable EmpResult = new DataTable();
            List<TimeControlGrid> GridList = new List<TimeControlGrid>();


            //int count = 25;
            for (int i = 0; i < 50; i++)
            {
                GridList.Add(new TimeControlGrid()
                {
                    EmpNumber = Convert.ToInt32(i),
                    EmpName = new Employee() { EmployeeName = "emp" + i.ToString(), EmployeeNumber = Convert.ToInt32(i) },
                    Dept = new Department() { DeptName = "dept" + i.ToString() },
                    ProjectName = new Project() { ProjectName = "proj name" + i.ToString(), ProjCode =i.ToString() },
                    ChargeDesc = new ChargeCode() { ChargeCodeName = "charge name" + i.ToString() },
                    ProjectCode = new Project() { ProjectName = i.ToString(), ProjCode =i.ToString() },
                    CostCenter = new CostCenter() { CostCenterName = "cost name" + i.ToString() },
                    Jan = Convert.ToInt32(i),
                    Feb = Convert.ToInt32(i),
                    Mar = Convert.ToInt32(i),
                    Apr = Convert.ToInt32(i),
                    May = Convert.ToInt32(i),
                    Jun = Convert.ToInt32(i),
                    Jul = Convert.ToInt32(i),
                    Aug = Convert.ToInt32(i),
                    Sep = Convert.ToInt32(i),
                    Oct = Convert.ToInt32(i),
                    Nov = Convert.ToInt32(i),
                    Dec = Convert.ToInt32(i),
                    HoursYTD = (Convert.ToInt32(i) * 12)
                });

            }

            return Json(GridList.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult LoadHoursByProject()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());

            List<HoursByProject> EmpList = new List<HoursByProject>();

            int count = 25;
            for (int i = 0; i < 25; i++)
            {
                EmpList.Add(new HoursByProject()
                {
                    Hours = Convert.ToInt32(i),
                    ProjectName = "hours" + i.ToString()
                });
            }

            return Json(EmpList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult GetProjectNames()
        {
            List<Project> EmpList = new List<Project>();
            int count = 25;
            for (int i = 0; i < 25; i++)
            {
                EmpList.Add(new Project()
                {
                    ProjCode = i.ToString(),
                    ProjectName = "ProjName" + i.ToString()
                });
            }

            return Json(EmpList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public JsonResult GetAllEmloyees()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());
            List<Employee> EmpList = new List<Employee>();

            int count = 25;
            for (int i = 0; i < 25; i++)
            {
                Random rnd = new Random();
                int month = rnd.Next(1, 25);
                EmpList.Add(new Employee()
                {
                    EmployeeNumber = Convert.ToInt32(i),
                    EmployeeName = "empName" + month.ToString()
                });
            }

            return Json(EmpList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public JsonResult GetDepartmentNames()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());
            List<Department> DeptList = new List<Department>();
            int count = 25;
            for (int i = 0; i < 25; i++)
            {
                Random rnd = new Random();
                int month = rnd.Next(1, 25);
                DeptList.Add(new Department()
                {

                    DeptName = "deptName" + month.ToString()
                });
            }

            

            return Json(DeptList, JsonRequestBehavior.AllowGet);
        }


        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public JsonResult GetChargecodeDesc(string ProjectName)
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());
            List<ChargeCode> DeptList = new List<ChargeCode>();
            int count = 25;
            for (int i = 0; i < 25; i++)
            {
                Random rnd = new Random();
                int month = rnd.Next(1, 25);
                DeptList.Add(new ChargeCode()
                {

                    ChargeCodeName = "chargeName" + month.ToString()
                });
            }

            return Json(DeptList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public JsonResult GetCostCenters()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());
            List<CostCenter> DeptList = new List<CostCenter>();
            int count = 25;
            for (int i = 0; i < 25; i++)
            {
                Random rnd = new Random();
                int month = rnd.Next(1, 25);
                DeptList.Add(new CostCenter()
                {

                    CostCenterName = "costcenterName" + month.ToString()
                });
            }

            return Json(DeptList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult AddProject()
        {
            return PartialView("AddProject");
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult SubmitAddNewProject(Project NewProj)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnection"].ToString()))
                    {
                        SqlCommand cmd;
                       
                        cmd = new SqlCommand("insert into Projects(ProjectID,ProjectName) values(@ProjectID,@ProjectName)", con);
                        con.Open();
                        cmd.Parameters.AddWithValue("@ProjectID", NewProj.ProjCode);
                        cmd.Parameters.AddWithValue("@ProjectName", NewProj.ProjectName);
                        cmd.ExecuteNonQuery();
                        con.Close();                       
                    }
                    return RedirectToAction("Index");
                }
                catch (Exception)
                {

                    throw;
                }
            }
            else
            {
                return null;
            }
        }


        public ActionResult HoursByResource()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());           

            return View();
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult LoadHoursByResource()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());
            DataTable result = new DataTable();
           


            List<ResourceByProject> EmpList = new List<ResourceByProject>();
            EmpList = (from DataRow dr in result.Rows
                       select new ResourceByProject()
                       {
                           Hours = Convert.ToInt32(dr["HOURS"]),
                           EmpName = dr["EMH_NAME"].ToString()

                       }).ToList();

            return Json(EmpList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult LoadHoursByResourceWithDetails()
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());
            DataTable result = new DataTable();
            


            List<ResourceByProject> EmpList = new List<ResourceByProject>();
            EmpList = (from DataRow dr in result.Rows
                       select new ResourceByProject()
                       {
                           CostCenterName= dr["COSTCENTER"].ToString(),
                           Hours = Convert.ToInt32(dr["HOURS"]),
                           ProjectName = dr["PROJECTNAME"].ToString(),
                           EmpName = dr["EMH_NAME"].ToString()

                       }).ToList();

            return Json(EmpList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult TurnOffProject()
        {
            return PartialView("TurnOffProject");
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult SubmitTurnOffProject(Project NewProj)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnection"].ToString()))
                    {
                        SqlCommand cmd;

                        cmd = new SqlCommand("update Projects set IsActive=@IsActive where ProjectCode=@ProjectCode", con);
                        con.Open();
                        cmd.Parameters.AddWithValue("@IsActive", "0");
                        cmd.Parameters.AddWithValue("@ProjectCode", NewProj.ProjectName);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                    return RedirectToAction("Index");
                }
                catch (Exception)
                {

                    throw;
                }
            }
            else
            {
                return View();
            }
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult TurnOffResource()
        {
            return PartialView("TurnOffResource");
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult SubmitTurnOffResource(Employee emp)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnection"].ToString()))
                    {
                        SqlCommand cmd;

                        cmd = new SqlCommand("update Employee set IsActive=@IsActive where EmpName=@EmpName", con);
                        con.Open();
                        cmd.Parameters.AddWithValue("@IsActive", "0");
                        cmd.Parameters.AddWithValue("@EmpName", emp.EmployeeName);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                    return RedirectToAction("Index");
                }
                catch (Exception)
                {

                    throw;
                }
            }
            else
            {
                return View();
            }
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public JsonResult GetTurnOffProjects([DataSourceRequest] DataSourceRequest request)
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());

            List<Project> DeptList = new List<Project>();
            int count = 25;
            for (int i = 0; i < 2; i++)
            {
                DeptList.Add(new Project()
                {
                    ProjCode = i.ToString(),
                    ProjectName = "proj name0"
                });
            }


           

            return Json(DeptList, JsonRequestBehavior.AllowGet);
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public JsonResult GetTurnOffResources([DataSourceRequest] DataSourceRequest request)
        {
            //return Json(ChartDataRepository.SpainElectricityProduction());

            List<Project> DeptList = new List<Project>();
            int count = 25;
            for (int i = 0; i < 2; i++)
            {
                DeptList.Add(new Project()
                {
                    ProjCode = i.ToString(),
                    ProjectName = "emp0"
                });
            }

            return Json(DeptList, JsonRequestBehavior.AllowGet);
        }
        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult SaveMyPageView(string Filters)
        {

            try
            {

               
                return RedirectToAction("Index");
            }
            catch (Exception e)
            {

                throw;
            }
        }
        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public string GetMyPageView()
        {

            try
            {

                string outout = "ProjectName.ProjectName,eq,proj name1,ProjectName.ProjectName,eq,proj name5,";

                return outout;
                //return RedirectToAction("Index");
            }
            catch (Exception e)
            {

                throw;
            }
        }
    }

    
}
