コード例 #1
0
        public async Task <IActionResult> AddTimeSheet(TimeSheetInputModel inputModel)
        {
            ViewBag.userMenu = GetMenu();

            var loggedInUser     = HttpContext.User;
            var loggedInUserName = loggedInUser.Identity.Name;



            var tsFunc = (from x in context.TimeSheet where x.FunctionId.Equals(inputModel.FunctionId)
                          orderby x.TimeSheetNumber descending
                          select x

                          ).FirstOrDefault();

            Boolean X = Boolean.ReferenceEquals(tsFunc, null);

            int num;

            if (X)
            {
                num = 100000;
            }
            else
            {
                num = Convert.ToInt32(tsFunc.TimeSheetNumber);
                num = num + 1;
            }

            var uid = (from u in context.UserSspm where u.Username.Equals(loggedInUserName) select u).FirstOrDefault();

            TimeSheet ord = new TimeSheet
            {
                ProjectNumber   = inputModel.ProjectNumber,
                TaskId          = inputModel.TaskId,
                FunctionId      = inputModel.FunctionId,
                TimeSheetId     = DateTime.Now,
                TimeSheetStart  = inputModel.TimeSheetStart,
                TimeSheetEnd    = inputModel.TimeSheetEnd,
                UserId          = uid.UserId,
                TimeSheetNumber = num.ToString(),
                ActionId        = "N"
            };

            try
            {
                context.TimeSheet.Add(ord);
                await context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                // Provide for exceptions.
            }

            return(RedirectToAction("TimeSheet", "TimeSheet", new RouteValueDictionary(
                                        new { Controller = "TimeSheet", Action = "TimeSheet", id = inputModel.ProjectNumber })));
        }
コード例 #2
0
        public IActionResult Result(string id)
        {
            ViewBag.userMenu = GetMenu();
            ViewBag.nothi    = Nothi();


            var pjd = (from p in context.Project join u in context.UserSspm on p.ProjectManager equals u.UserId
                       where p.ProjectNumber.Equals(id)
                       select new ResultProjectModel
            {
                ProjectNumber = p.ProjectNumber,
                ProjectId = p.ProjectId,
                ProjectName = p.ProjectName,
                ProjectManager = u.Firstname + " " + u.Lastname,
                ProjectCost = p.ProjectCost,
                CustomerName = p.CustomerName,
                CustomerTel = p.CustomerTel,
                ProjectStart = p.ProjectStart,
                ProjectEnd = p.ProjectEnd,
                ActualStart = p.ActualStart,
                ActualEnd = p.ActualEnd
            }
                       ).FirstOrDefault();

            ViewData["projectDetile"] = pjd;



            var joinyub = (from TT in context.TeamTask
                           join FC in context.Function on TT.FunctionId equals FC.FunctionId
                           join TSK in context.Task on FC.TaskId equals TSK.TaskId
                           join PJ in context.Project on TSK.ProjectNumber equals PJ.ProjectNumber
                           join USR in context.UserSspm on TT.UserId equals USR.UserId
                           where PJ.ProjectNumber.Equals(id)
                           select new
            {
                TaskName = TSK.TaskName,
                TaskId = TSK.TaskId,
                TaskStart = TSK.TaskStart,
                TaskEnd = TSK.TaskEnd,
                TActualStart = TSK.ActualStart,
                TActualEnd = TSK.ActualEnd,

                FunctionName = FC.FunctionName,
                FunctionId = FC.FunctionId,
                FunctionStart = FC.FunctionStart,
                FunctionEnd = FC.FunctionEnd,
                FActualStart = FC.ActualStart,
                FActualEnd = FC.ActualEnd,
                Username = USR.Firstname + " " + USR.Lastname,
            }).ToList();

            List <ResultModel> model = new List <ResultModel>();

            foreach (var item in joinyub)
            {
                var     statnow = "";
                Boolean X       = Boolean.ReferenceEquals(item.FActualEnd, null);
                if (X)
                {
                    Boolean Y = Boolean.ReferenceEquals(item.FActualStart, null);
                    if (Y)
                    {
                        statnow = "Not Started";
                    }
                    else
                    {
                        statnow = "Process";
                    }
                }
                else
                {
                    statnow = "Finished";
                }
                model.Add(new ResultModel()
                {
                    TaskName     = item.TaskName,
                    TaskId       = item.TaskId,
                    TaskStart    = item.TaskStart,
                    TaskEnd      = item.TaskEnd,
                    TActualStart = item.TActualStart,
                    TActualEnd   = item.TActualEnd,

                    FunctionName  = item.FunctionName,
                    FunctionId    = item.FunctionId,
                    FunctionStart = item.FunctionStart,
                    FunctionEnd   = item.FunctionEnd,
                    FActualStart  = item.FActualStart,
                    FActualEnd    = item.FActualEnd,
                    Username      = item.Username,
                    Status        = statnow
                });
            }

            return(View(model));
        }
コード例 #3
0
        public async Task <IActionResult> ChatBulletin(CreateBulletinModel inputModel)
        {
            ViewBag.userMenu = GetMenu();
            ViewBag.nothi    = Nothi();

            if (!ModelState.IsValid)
            {
                return(View());
            }


            try
            {
                var loggedInUser     = HttpContext.User;
                var loggedInUserName = loggedInUser.Identity.Name;

                var user = (from u in context.UserSspm where u.Username.Equals(loggedInUserName) select u).FirstOrDefault();

                var ChatNum = (from x in context.BulletinChat
                               where x.Bnumber.Equals(inputModel.Bnumber)
                               orderby x.Bchat descending
                               select x

                               ).FirstOrDefault();

                Boolean X = Boolean.ReferenceEquals(ChatNum, null);

                int num;
                if (X)
                {
                    num = 100000;
                }
                else
                {
                    num = Convert.ToInt32(ChatNum.Bchat);
                    num = num + 1;
                }

                Models.BulletinChat ord = new Models.BulletinChat
                {
                    UserId  = user.UserId,
                    Chat    = inputModel.Chat,
                    Ctime   = DateTime.Now,
                    Bnumber = inputModel.Bnumber,
                    Bchat   = num.ToString(),
                };


                // Add the new object to the Orders collection.
                context.BulletinChat.Add(ord);
                await context.SaveChangesAsync();


                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                return(View());
            }
        }