public JsonResult RegisterUser(CUser model)
        {
            CUser cUser = new CUser();

            if (!cUser.userNameAvailable(model.userName))
            {
                return(Json("Användarnamn upptaget. Välj ett annat namn.", JsonRequestBehavior.AllowGet));
            }
            if (!cUser.emailAvailable(model.email))
            {
                return(Json("Denna emailadress finns redan i systemet.", JsonRequestBehavior.AllowGet));
            }

            string resultText = "Success";

            try
            {
                pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
                userTbl u = new userTbl();
                u.userName   = model.userName;
                u.email      = model.email;
                u.userRoleId = model.userRoleId;
                u.password   = model.password;

                u.regDate = System.DateTime.Now;

                db.userTbl.Add(u);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                resultText = "Error while inserting user. Error message : " + ex.Message;
            }
            return(Json(resultText, JsonRequestBehavior.AllowGet));
        }
        public JsonResult getProjects(DataTablesParam param, int customerID)
        {
            int    pageNo = 1;
            string crit   = "";

            if (param.sSearch != null)
            {
                crit = param.sSearch.ToUpper();
            }
            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
            int totalCount           = db.project.Where(x => x.customerID == customerID).Count();
            //int totalCount = db.project.Count();
            List <CProject> projList = db.project.Select(x => new CProject
            {
                projectID   = x.projectID,
                customerID  = x.customerID,
                projectName = x.projectName,
                active      = x.active
            }).Where(x => x.customerID == customerID).ToList();


            if (crit != null && crit != "")
            {
                projList = projList.Where(x => x.projectName.ToUpper().Contains(crit)).ToList();
            }

            if (param.iSortCol_0 == 0 && param.sSortDir_0 == "asc")
            {
                projList = projList.OrderBy(o => o.projectName).ToList();
            }
            if (param.iSortCol_0 == 0 && param.sSortDir_0 == "desc")
            {
                projList = projList.OrderByDescending(o => o.projectName).ToList();
            }
            if (param.iSortCol_0 == 1 && param.sSortDir_0 == "asc")
            {
                projList = projList.OrderBy(o => o.active).ToList();
            }
            if (param.iSortCol_0 == 1 && param.sSortDir_0 == "desc")
            {
                projList = projList.OrderByDescending(o => o.active).ToList();
            }

            int countToDisplay = projList.Count();

            projList = projList.Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();

            return(Json(new
            {
                aaData = projList,
                sEcho = param.sEcho,
                iTotalDisplayRecords = countToDisplay,
                iTotalRecords = totalCount
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddEditCust(int CustomerID)
        {
            pdsTidRedLiveEntities db   = new pdsTidRedLiveEntities();
            List <custType>       list = db.custType.ToList();

            ViewBag.UserRoleList = new SelectList(list, "custTypeID", "custType1");

            CCustomer model = new CCustomer();

            if (CustomerID > 0)
            {
                customer c = db.customer.SingleOrDefault(x => x.customerID == CustomerID);
                model.customerID = c.customerID;
                model.custTypeID = c.custTypeID;
                model.custName   = c.custName;
                model.address1   = c.address1;
                model.address2   = c.address2;
                model.zipCode    = c.zipCode;
                model.city       = c.city;
                model.email      = c.email;
                model.active     = c.active;
            }
            else
            {
                model.active = true;
            }
            return(PartialView("AddEditCust", model));
        }
        public JsonResult updateMyProjects(int projectId, bool selected)
        {
            string message = "";
            int    userId  = Convert.ToInt32(Session["userId"]);

            try
            {
                pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
                if (selected)
                {
                    if (db.userProject.Where(x => x.userId == userId && x.projectId == projectId).Count() == 0)
                    {
                        userProject up = new userProject();
                        up.userId    = userId;
                        up.projectId = projectId;
                        db.userProject.Add(up);
                        db.SaveChanges();
                    }
                }
                else
                {
                    userProject up = db.userProject.FirstOrDefault(x => x.userId == userId && x.projectId == projectId);
                    if (up != null)
                    {
                        db.userProject.Remove(up);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
        public JsonResult updateTimeTrack(CTimeTrack model)
        {
            string message = "";

            if (Session["userId"] == null)
            {
                message = "Ej inloggad";
            }
            if (message == "")
            {
                int                   userId = Convert.ToInt32(Session["userId"]);
                CTimeTrack            ct     = new CTimeTrack();
                pdsTidRedLiveEntities db     = new pdsTidRedLiveEntities();
                try
                {
                    if (model.timeTrackRowID == 0)
                    {
                        ct.addTimeTrack(model, userId);
                    }
                    else
                    {
                        ct.editTimeTrack(model, userId);
                    }
                }
                catch (Exception ex)
                {
                    message = ex.Message;
                }
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
        public JsonResult updateSubProject(CSubproject2 model)
        {
            string message = "";

            try
            {
                pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
                subProject2           p  = null;
                if (model.subProjectID == 0)
                {
                    p           = new subProject2();
                    p.projectID = model.projectID;
                }
                else
                {
                    p = db.subProject2.SingleOrDefault(x => x.subProjectID == model.subProjectID);
                }
                p.subProjectName = model.subProjectName;
                if (model.subProjectID == 0)
                {
                    db.subProject2.Add(p);
                }
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
        public JsonResult getTimeReg(DataTablesParam param, DateTime dFrom, DateTime dTo, int customerId, int projectId)
        {
            //Init and calculate variables
            int    pageNo = 1;
            string crit   = "";

            if (param.sSearch != null)
            {
                crit = param.sSearch.ToUpper();
            }
            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            pdsTidRedLiveEntities db              = new pdsTidRedLiveEntities();
            int               userId              = Convert.ToInt32(Session["userId"]);
            int               totalRecords        = 0;
            int               totalDisplayRecords = 0;
            CTimeTrack        ctt    = new CTimeTrack();
            List <CTimeTrack> listTT = ctt.getMyTimeTracks(param, userId, dFrom, dTo, customerId, projectId, ref totalRecords, ref totalDisplayRecords);

            return(Json(new
            {
                aaData = listTT,
                sEcho = param.sEcho,
                iTotalDisplayRecords = totalDisplayRecords,
                iTotalRecords = totalRecords
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult registerActivity()
        {
            pdsTidRedLiveEntities db           = new pdsTidRedLiveEntities();
            List <customer>       customerList = db.customer.OrderBy(x => x.custName).ToList();

            ViewBag.Customer = new SelectList(customerList, "customerID", "custName");
            return(View());
        }
        public ActionResult Registration()
        {
            pdsTidRedLiveEntities db           = new pdsTidRedLiveEntities();
            List <userRole>       userRoleList = db.userRole.ToList();

            ViewBag.UserRole = new SelectList(userRoleList, "userRoleId", "userRoleName");
            return(View());
        }
        public ActionResult GetProjectList(int CustomerId)
        {
            pdsTidRedLiveEntities db       = new pdsTidRedLiveEntities();
            List <project>        projList = db.project.Where(x => x.customerID == CustomerId).ToList();

            ViewBag.ProjList = new SelectList(projList, "projectID", "projectName");

            return(PartialView("GetProjectList"));
        }
        public ActionResult AddEditTimeTrack2(int timeTrackRowID, int customerID, int projectID)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();

            int userId = Convert.ToInt32(Session["userId"]);

            SelectList   custList    = null;
            SelectList   projList    = null;
            SelectList   subProjList = null;
            CTimeTrack   model       = new CTimeTrack();
            CSubproject2 cs2         = new CSubproject2();

            if (timeTrackRowID == 0)
            {
                model.timeTrackRowID = timeTrackRowID;
                model.tDate          = System.DateTime.Today;
                model.customerID     = customerID;
                //model.projectId = projectID;
                CTimeTrack ct = new CTimeTrack();
                custList = ct.getMyCustomers(userId);
                //projList = ctc.getMyCustProjects(userId, customerID);
                //subProjList = cs2.getSubProjects(0);
            }
            else
            {
                timeTrackRow ttr = db.timeTrackRow.FirstOrDefault(x => x.timeTrackRowID == timeTrackRowID);
                if (ttr != null)
                {
                    model.timeTrackHeadID = ttr.timeTrackHeadID;
                    model.customerID      = ttr.timeTrackHead.customerID;
                    model.tDate           = ttr.timeTrackHead.tDate;
                    model.userId          = ttr.timeTrackHead.userId;
                    model.timeTrackRowID  = ttr.timeTrackRowID;
                    model.subProjectID    = ttr.subProjectID;
                    model.hours           = ttr.hours;
                    model.regDate         = ttr.regDate;
                    model.note            = ttr.note;
                    model.projectId       = ttr.subProject2.projectID;
                    model.projectName     = ttr.subProject2.project.projectName;
                    model.customerName    = ttr.timeTrackHead.customer.custName;
                    model.timeTrackHeadID = ttr.timeTrackHeadID;
                }
                // First get the timeTrackHead

                /* custList = ctc.getMyCustomers(0, model.customerID);
                 * projList = ctc.getMyCustProjects(userId, ttr.timeTrackHead.customerID); */
            }
            ViewBag.custList    = custList;
            ViewBag.projList    = projList;
            subProjList         = cs2.getSubProjects(model.projectId);
            ViewBag.subProjList = subProjList;
            return(PartialView("AddEditTimeTrack", model));
        }
        // GET: TimeReg
        /// <summary>
        /// Index view
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            CDateParameters       ct = new CDateParameters();
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
            DateTime today           = DateTime.Today.AddDays(-1);
            DateTime dtStartDate     = today.AddDays(DayOfWeek.Monday - today.DayOfWeek);

            ct.dFrom = dtStartDate;
            ct.dTo   = dtStartDate.AddDays(6);

            int        userId = Convert.ToInt32(Session["userId"]);
            CTimeTrack ctc    = new CTimeTrack();

            ViewBag.myCustomers = ctc.getMyCustomers(userId);
            return(View(ct));
        }
        public ActionResult AddEditSubProj(int subProjectID, int ProjectID)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();

            CSubproject2 model = new CSubproject2();

            if (subProjectID > 0)
            {
                subProject2 p = db.subProject2.FirstOrDefault(x => x.subProjectID == subProjectID);
                model.subProjectID   = p.subProjectID;
                model.subProjectName = p.subProjectName;
                model.projectID      = p.projectID;
            }

            return(PartialView("AddEditSubProj", model));
        }
        public ActionResult AddEditProj(int ProjectID, int CustomerID)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();

            CProject model = new CProject();

            if (ProjectID > 0)
            {
                project p = db.project.FirstOrDefault(x => x.projectID == ProjectID);
                model.projectID   = p.projectID;
                model.projectName = p.projectName;
                model.customerID  = CustomerID;
                model.active      = p.active;
            }
            else
            {
                model.active = true;
            }

            return(PartialView("AddEditProj", model));
        }
Пример #15
0
        public ActionResult reportInterval()
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();

            ViewBag.dFrom = DateTime.Today;
            ViewBag.dTo   = DateTime.Today.AddDays(-30);
            List <customer> custList = db.customer.Where(x => x.active == true).OrderBy(x => x.custName).ToList();

            ViewBag.custList = new SelectList(custList, "customerID", "custName");

            List <userTbl> userList = db.userTbl.OrderBy(x => x.userName).ToList();

            ViewBag.userList = new SelectList(userList, "userId", "userName");

            CReportPeriod        crp        = new CReportPeriod();
            List <CReportPeriod> periodList = crp.getReportPeriods();
            SelectList           sl         = new SelectList(periodList, "reportPeriodId", "reportPeriodDescr");

            ViewBag.periodList = sl;
            return(View());
        }
        public ActionResult AddEditTimeTrack(int timeTrackRowID, int customerID, int projectID)
        {
            pdsTidRedLiveEntities db    = new pdsTidRedLiveEntities();
            CTimeTrack            model = new CTimeTrack();
            int userId = Convert.ToInt32(Session["userId"]);

            if (timeTrackRowID == 0)
            {
                model.timeTrackRowID = 0;
                model.userId         = userId;
                model.customerID     = customerID;
                model.projectId      = projectID;
                model.tDate          = System.DateTime.Today;
                CTimeTrack ct = new CTimeTrack();
                ViewBag.custList = ct.getMyCustomers(userId);
                ViewBag.projList = ct.getMyCustProjects(userId, customerID);
                CSubproject2 cs2 = new CSubproject2();
                ViewBag.subProjList = cs2.getSubProjects(projectID);
                return(PartialView("AddTimeTrack", model));
            }
            else
            {
                timeTrackRow ttr = db.timeTrackRow.FirstOrDefault(x => x.timeTrackRowID == timeTrackRowID);
                if (ttr != null)
                {
                    model.tDate           = ttr.timeTrackHead.tDate;
                    model.subProjectID    = ttr.subProjectID;
                    model.hours           = ttr.hours;
                    model.note            = ttr.note;
                    model.projectName     = ttr.subProject2.project.projectName;
                    model.customerName    = ttr.timeTrackHead.customer.custName;
                    model.tDateStr        = ttr.timeTrackHead.tDate.ToShortDateString();
                    model.timeTrackHeadID = ttr.timeTrackHeadID;
                    model.customerID      = ttr.timeTrackHead.customerID;
                    CSubproject2 cs2 = new CSubproject2();
                    ViewBag.subProjList = cs2.getSubProjects(ttr.subProject2.projectID);
                }
            }
            return(PartialView("EditTimeTrack", model));
        }
        public JsonResult updateProject(CProject model)
        {
            string message = "";
            bool   bNew    = false;
            int    projID  = 0;

            try
            {
                pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
                project p = null;
                if (model.projectID == 0)
                {
                    p            = new project();
                    p.customerID = model.customerID;
                    bNew         = true;
                }
                else
                {
                    p = db.project.SingleOrDefault(x => x.projectID == model.projectID);
                }
                p.projectName = model.projectName;
                p.active      = model.active;
                if (model.projectID == 0)
                {
                    db.project.Add(p);
                }
                db.SaveChanges();
                projID = p.projectID;
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            if (message == "" && bNew)
            {
                CSubproject2 cs2 = new CSubproject2();
                message = cs2.addStdActivity(projID);
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
        public JsonResult LoginUser(CUser model)
        {
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();

            userTbl user   = db.userTbl.SingleOrDefault(x => x.userName == model.userName && x.password == model.password);
            string  result = "Felaktigt användarnamn eller lösenord";

            if (user != null)
            {
                Session["userId"]   = user.userId;
                Session["userName"] = user.userName;
                if (user.userRole.roleLevel == 10)
                {
                    result = "Admin";
                }
                else
                {
                    result = "User";
                }
                Session["roleLevel"] = user.userRole.roleLevel.ToString();
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public JsonResult updateCustomer(CCustomer model)
        {
            string message = "";

            try
            {
                pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();
                customer c = null;
                if (model.customerID == 0)
                {
                    c = new customer();
                }
                else
                {
                    c = db.customer.SingleOrDefault(x => x.customerID == model.customerID);
                }
                c.custName   = model.custName;
                c.custTypeID = model.custTypeID;
                c.email      = model.email;
                c.address1   = model.address1;
                c.address2   = model.address2;
                c.zipCode    = model.zipCode;
                c.city       = model.city;
                c.active     = model.active;
                if (model.customerID == 0)
                {
                    db.customer.Add(c);
                }
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
        public JsonResult getAllCustomers(DataTablesParam param)
        {
            int    pageNo = 1;
            string crit   = "";

            if (param.sSearch != null)
            {
                crit = param.sSearch.ToUpper();
            }
            if (param.iDisplayStart >= param.iDisplayLength)
            {
                pageNo = (param.iDisplayStart / param.iDisplayLength) + 1;
            }

            pdsTidRedLiveEntities db  = new pdsTidRedLiveEntities();
            int totalCount            = db.customer.Count();
            List <CCustomer> custList = db.customer.Select(x => new CCustomer
            {
                customerID   = x.customerID,
                custName     = x.custName,
                custTypeID   = x.custTypeID,
                address1     = x.address1,
                address2     = x.address2,
                zipCode      = x.zipCode,
                city         = x.city,
                email        = x.email,
                custTypeName = x.custType.custType1,
                toBeInvoiced = x.custType.toBeInvoiced,
                active       = x.active
            }).ToList();

            if (crit != null && crit != "")
            {
                custList = custList.Where(x => x.custName.ToUpper().Contains(crit)).ToList();
            }



            if (param.iSortCol_0 == 0 && param.sSortDir_0 == "asc")
            {
                custList = custList.OrderBy(o => o.custName).ToList();
            }
            if (param.iSortCol_0 == 0 && param.sSortDir_0 == "desc")
            {
                custList = custList.OrderByDescending(o => o.custName).ToList();
            }
            if (param.iSortCol_0 == 1 && param.sSortDir_0 == "asc")
            {
                custList = custList.OrderBy(o => o.custTypeName).ToList();
            }
            if (param.iSortCol_0 == 1 && param.sSortDir_0 == "desc")
            {
                custList = custList.OrderByDescending(o => o.custTypeName).ToList();
            }
            if (param.iSortCol_0 == 2 && param.sSortDir_0 == "asc")
            {
                custList = custList.OrderBy(o => o.address1).ToList();
            }
            if (param.iSortCol_0 == 2 && param.sSortDir_0 == "desc")
            {
                custList = custList.OrderByDescending(o => o.address1).ToList();
            }
            if (param.iSortCol_0 == 3 && param.sSortDir_0 == "asc")
            {
                custList = custList.OrderBy(o => o.city).ToList();
            }
            if (param.iSortCol_0 == 3 && param.sSortDir_0 == "desc")
            {
                custList = custList.OrderByDescending(o => o.city).ToList();
            }
            if (param.iSortCol_0 == 4 && param.sSortDir_0 == "asc")
            {
                custList = custList.OrderBy(o => o.email).ToList();
            }
            if (param.iSortCol_0 == 4 && param.sSortDir_0 == "desc")
            {
                custList = custList.OrderByDescending(o => o.email).ToList();
            }

            int countToDisplay = custList.Count();

            custList = custList.Skip((pageNo - 1) * param.iDisplayLength).Take(param.iDisplayLength).ToList();


            return(Json(new
            {
                aaData = custList,
                sEcho = param.sEcho,
                iTotalDisplayRecords = countToDisplay,
                iTotalRecords = totalCount,
            }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult updateTimeTrack3(CTimeTrack model)
        {
            string message = "";
            // 2018-04-03 KJBO
            int userId = Convert.ToInt32(Session["userId"]);


            CTimeTrack            ct = new CTimeTrack();
            pdsTidRedLiveEntities db = new pdsTidRedLiveEntities();

            try
            {
                if (model.timeTrackRowID == 0)
                {
                    ct.addTimeTrack(model, userId);

/*                    timeTrackHead th = db.timeTrackHead.FirstOrDefault(x => x.customerID == model.customerID
 *                  && x.userId == userId && x.tDate == model.tDate);
 *                  if (th == null)
 *                  {
 *                      int ttHeadId = db.timeTrackHead.Max(x => x.timeTrackHeadID);
 *                      ttHeadId++;
 *                      th = new timeTrackHead();
 *                      th.timeTrackHeadID = ttHeadId;
 *                      th.customerID = model.customerID;
 *                      th.userId = userId;
 *                      th.tDate = model.tDate;
 *                      db.timeTrackHead.Add(th);
 *                      db.SaveChanges();
 *                  }
 *                  model.timeTrackHeadID = th.timeTrackHeadID;
 *                  int ttRowId = db.timeTrackRow.Max(x => x.timeTrackRowID);
 *                  ttRowId++;
 *                  timeTrackRow tr = new timeTrackRow();
 *                  tr.timeTrackHeadID = model.timeTrackHeadID;
 *                  tr.timeTrackRowID = ttRowId;
 *                  tr.hours = model.hours;
 *                  tr.note = model.note;
 *                  tr.regDate = System.DateTime.Now;
 *                  tr.subProjectID = model.subProjectID;
 *                  db.timeTrackRow.Add(tr);
 *                  db.SaveChanges(); */
                }
                else
                {
                    ct.editTimeTrack(model, userId);

                    /*
                     * // First get the timeTrackHead to check if the date is the same as before
                     * timeTrackHead th = db.timeTrackHead.FirstOrDefault(x => x.timeTrackHeadID == model.timeTrackHeadID);
                     * if (th.tDate != model.tDate)
                     * {
                     *  int customerId = th.customerID;
                     *  int ttHeadId = db.timeTrackHead.Max(x => x.timeTrackHeadID);
                     *  ttHeadId++;
                     *  th = new timeTrackHead();
                     *  th.timeTrackHeadID = ttHeadId;
                     *  th.customerID = customerId;
                     *  th.userId = userId;
                     *  th.tDate = model.tDate;
                     *  db.timeTrackHead.Add(th);
                     *  db.SaveChanges();
                     *  model.timeTrackHeadID = th.timeTrackHeadID;
                     *
                     *  // Here we have work to do. First check if there are other timeTracks that uses the same timeTrackRow
                     *  int cntTTh = db.timeTrackRow.Where(x => x.timeTrackHeadID == model.timeTrackHeadID).Count();
                     *  if (cntTTh == 1)
                     *  {
                     *      // In this case, only the current row points to this head and we can easily change the date without any problems
                     *      th.tDate = model.tDate;
                     *      db.SaveChanges();
                     *  }
                     *  else
                     *  {
                     *      // Check if there exists one timeTrackHead with the same values and in that case use that
                     *      th = db.timeTrackHead.FirstOrDefault(x => x.customerID == model.customerID
                     *          && x.userId == userId && x.tDate == model.tDate);
                     *      if (th != null)
                     *          model.timeTrackHeadID = th.timeTrackHeadID;
                     *      else
                     *      {
                     *          int ttHeadId = db.timeTrackHead.Max(x => x.timeTrackHeadID);
                     *          ttHeadId++;
                     *          th = new timeTrackHead();
                     *          th.timeTrackHeadID = ttHeadId;
                     *          th.customerID = model.customerID;
                     *          th.userId = userId;
                     *          th.tDate = model.tDate;
                     *          db.timeTrackHead.Add(th);
                     *          db.SaveChanges();
                     *          model.timeTrackHeadID = th.timeTrackHeadID;
                     *      }
                     *
                     *  }
                     *
                     * }
                     * timeTrackRow tr = db.timeTrackRow.FirstOrDefault(x => x.timeTrackRowID == model.timeTrackRowID);
                     * tr.timeTrackHeadID = model.timeTrackHeadID;
                     * tr.subProjectID = model.subProjectID;
                     * tr.hours = model.hours;
                     * tr.note = model.note;
                     * db.SaveChanges();
                     *
                     * }
                     *
                     * subProject2 p = null;
                     * if (model.subProjectID == 0)
                     * {
                     * p = new subProject2();
                     * p.projectID = model.projectID;
                     * }
                     * else
                     * p = db.subProject2.SingleOrDefault(x => x.subProjectID == model.subProjectID);
                     * p.subProjectName = model.subProjectName;
                     * if (model.subProjectID == 0)
                     * db.subProject2.Add(p);
                     * db.SaveChanges();
                     */
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(Json(message, JsonRequestBehavior.AllowGet));
        }