Пример #1
0
        public ActionResult Index(int?page, int?size, string msg, AlertMsgType?msgType,
                                  string src = "")
        {
            List <TblUnit> lst = new List <TblUnit>();

            try
            {
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                int total = uow.Modules.Unit.Count(src);
                WidgetPaginationModel Pagination = new WidgetPaginationModel(MVCAction, MVCController, MVCArea)
                {
                    Page      = (page ?? 1),
                    Size      = (size ?? 10),
                    SearchCri = new Dictionary <string, dynamic>()
                    {
                        { "src", src }
                    },
                    SortExp = "",
                    Total   = total
                };
                ViewBag.Pagination = Pagination;
                lst = uow.Modules.Unit.Gets(Pagination.Page, Pagination.Size, src);
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage(true)
                };
                ViewBag.Alert = Alert;
            }
            return(View(lst));
        }
Пример #2
0
        public ActionResult Index(int?page, int?size, string msg, AlertMsgType?msgType)
        {
            SysRole role = CurrentUser.Role(3).Role();

            ViewBag.canWrite  = role.SysRolePermission.Where(x => x.MenuId == 3920 && x.PermissionId == 2 && x.PermissionFlag).Count() > 0;
            ViewBag.canDelete = role.SysRolePermission.Where(x => x.MenuId == 3920 && x.PermissionId == 3 && x.PermissionFlag).Count() > 0;
            List <SysRole> lst = new List <SysRole>();

            try
            {
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                int total = uow.Role.Counts(SITE_ID);
                WidgetPaginationModel Pagination = new WidgetPaginationModel("Index", "Role", "")
                {
                    Page    = (page ?? 1),
                    Size    = (size ?? 10),
                    SortExp = "",
                    Total   = total
                };
                ViewBag.Pagination = Pagination;
                lst = uow.Role.Gets(Pagination.Page, Pagination.Size, SITE_ID);
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage()
                };
                ViewBag.Alert = Alert;
            }
            return(View(lst));
        }
Пример #3
0
        private ActionResult ViewDetail(TblInvoice ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }

                ViewData["optSaleOrder"] = uow.Modules.SaleOrder.Gets()
                                           .Where(so => so.StatusId == 1)
                                           .ToList();
                ViewData["optQuotation"] = uow.Modules.Quotation.Gets()
                                           .Where(q => q.StatusId == 3)
                                           .ToList();

                ViewData["optPayment"] = uow.Modules.PaymentCondition.Gets();

                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #4
0
        private ActionResult ViewStation(TblKptStation ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                return(View("Station", ob));
            }
            catch (Exception ex)
            {
                if (ob == null)
                {
                    return(RedirectToAction("Index", new
                    {
                        controller = "KPT",
                        msg = ex.GetMessage(),
                        msgType = AlertMsgType.Danger
                    }));
                }
                return(RedirectToAction("Detail", new
                {
                    id = ob.KptId,
                    controller = "KPT",
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
        private ActionResult ViewDetail(TransferStockHeader ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }


                ViewData["optCustomer"]        = uow.Modules.Customer.GetAllAddress();
                ViewData["optCustomerAddress"] = uow.Modules.CustomerAddress.Gets();
                ViewData["optProduct"]         = uow.Modules.Product.Gets();
                ViewData["optContact"]         = uow.Modules.CustomerContact.Gets();
                ViewData["optEmployee"]        = uow.Modules.Employee.Gets();
                ViewData["optWareHouse"]       = uow.Modules.WareHouse.Gets();
                CurrentUser.TblEmployee        = uow.Modules.Employee.GetEmployeeByAccount(CurrentUID);
                ViewData["userAccount"]        = CurrentUser;
                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #6
0
        private ActionResult ViewDetail(TblPayment ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                AccountPermission permission = new AccountPermission();
                permission = GetPermissionSale(CurrentUser.AccountId, ob.CreatedBy);

                ViewData["optBankAccount"] = uow.Modules.BankAccount.GetList(1);
                CurrentUser.TblEmployee    = uow.Modules.Employee.GetEmployeeByAccount(CurrentUID);
                ViewData["userAccount"]    = CurrentUser;
                ViewData["optPermission"]  = permission;
                ViewData["optEmployee"]    = uow.Modules.Employee.Gets();
                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #7
0
        private ActionResult ViewDetail(TblEmployee ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                ViewData["optPrefix"]     = uow.Modules.Enum.PrefixGets();
                ViewData["optDepartment"] = uow.Modules.Department.Gets();
                ViewData["optPosition"]   = uow.Modules.Position.Gets(1, 0);
                ViewData["optLead"]       = uow.Modules.Employee.Gets();
                ViewData["optAccount"]    = uow.Modules.Account.Gets();

                ViewData["optEmpPermission"] = uow.Modules.EmployeeUserPermission.Gets(src: ob.AccountId.ToString());
                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #8
0
        private ActionResult ViewDetail(SysAccount ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                ViewData["optRole"]    = uow.Role.Gets(1, 0, 3);
                ViewData["optRoleCal"] = uow.Role.Gets(1, 0, 3);
                ViewData["optStaff"]   = (from d in db.SysAccount
                                          where d.AccountId != ob.AccountId &&
                                          !db.CalcAccountStaff.Where(x => x.AccountId == ob.AccountId).Select(x => x.AccountId).Contains(d.AccountId)
                                          select d).ToList();
                return(View("Detail", ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", new
                {
                    area = "",
                    controller = "Account",
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #9
0
        public ActionResult Index(int?page, int?size, string msg, AlertMsgType?msgType)
        {
            List <SysRole> lst = new List <SysRole>();

            try
            {
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                int total = uow.Modules.Role.Counts(SiteId);
                WidgetPaginationModel Pagination = new WidgetPaginationModel("Index", "Role", "")
                {
                    Page    = (page ?? 1),
                    Size    = (size ?? 10),
                    SortExp = "",
                    Total   = total
                };
                ViewBag.Pagination = Pagination;
                lst = uow.Modules.Role.Gets(Pagination.Page, Pagination.Size, SiteId);
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage()
                };
                ViewBag.Alert = Alert;
            }
            return(View(lst));
        }
Пример #10
0
        private ActionResult ViewDetail(TblProduct ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                ViewData["optCategory"]  = uow.Modules.ProductCategory.Gets();
                ViewData["optModel"]     = uow.Modules.ProductModel.Gets();
                ViewData["optUnit"]      = uow.Modules.Unit.Gets();
                ViewData["optWareHouse"] = uow.Modules.WareHouse.Gets();

                ViewData["optProductOfWareHouse"] = uow.Modules.ProductOfWareHouse.Gets(ob.ProductId);

                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #11
0
        private ActionResult ViewDetail(TeamOperation ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }


                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                ViewData["optOperation"] = uow.Modules.TeamOperation.GetNotMembers();
                AccountPermission permission = new AccountPermission();
                permission = GetPermissionOperation(CurrentUser.AccountId, null);
                ViewData["userAccount"]   = CurrentUser;
                ViewData["optPermission"] = permission;
                return(View("Detail", ob));
            }
            catch (Exception ex)
            {
                Dictionary <string, dynamic> rs = new Dictionary <string, dynamic>()
                {
                    { "msg", ex.GetMessage() },
                    { "msgType", AlertMsgType.Danger }
                };
                return(UrlRedirect(PathHelper.OperationTeam, rs));
            }
        }
Пример #12
0
        public ActionResult GetTransferSInList()
        {
            List <TransferHeader> lst = new List <TransferHeader>();

            try
            {
                lst = uow.Modules.Transfer.GetList("I");
                foreach (var ls in lst.ToList())
                {
                    ls.StrTransferDate = ls.TransferDate.HasValue ? ls.TransferDate.Value.Day.ToString("00") + "/" + ls.TransferDate.Value.Month.ToString("00") + "/" + ls.TransferDate.Value.Year : "";
                }
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage(true)
                };
                ViewBag.Alert = Alert;
            }
            return(Json(lst));
        }
Пример #13
0
        private ActionResult ViewDetail(SysAccount ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                ViewData["optRole"]    = uow.Modules.Role.Gets(1, 0, SiteId);
                ViewData["optRoleCal"] = uow.Modules.Role.Gets(1, 0, 2);
                return(View("Detail", ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", new
                {
                    area = "",
                    controller = "Account",
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #14
0
        private ActionResult ViewDetail(TransferHeader ob, string msg, AlertMsgType?msgType)
        {
            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                AccountPermission permission = new AccountPermission();
                if (ob.JobOrder != null)
                {
                    ob.JobOrder.Team = uow.Modules.TeamOperation.Get(ob.JobOrder.TeamId.HasValue ? ob.JobOrder.TeamId.Value : 0);
                    permission       = GetPermissionOperation(CurrentUID, ob.JobOrder.Team);
                }
                else
                {
                    List <TeamOperation> manager = uow.Modules.TeamOperation.Manager(CurrentUID);
                    if (manager != null)
                    {
                        permission.IsManager   = true;
                        permission.IsEdit      = true;
                        permission.IsTeam      = true;
                        permission.IsAdminTeam = false;
                    }
                }

                ViewData["optCustomer"]        = uow.Modules.Customer.GetAllAddress();
                ViewData["optCustomerAddress"] = uow.Modules.CustomerAddress.Gets();
                ViewData["optProduct"]         = uow.Modules.Product.Gets();
                ViewData["optContact"]         = uow.Modules.CustomerContact.Gets();
                ViewData["optEmployee"]        = uow.Modules.Employee.Gets();
                ViewData["userAccount"]        = CurrentUser;
                ViewData["optPermission"]      = permission;
                if (ob.RefTransferId != null)
                {
                    ob.RefTransfer = uow.Modules.Transfer.GetTransferHeader(ob.TransferId);
                }
                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }
Пример #15
0
        public ActionResult Index(int?page, int?size, string msg, AlertMsgType?msgType)
        {
            SysRole role = CurrentUser.Role(3).Role();

            ViewBag.canWrite  = role.SysRolePermission.Where(x => x.MenuId == 3220 && x.PermissionId == 2 && x.PermissionFlag).Count() > 0;
            ViewBag.canDelete = role.SysRolePermission.Where(x => x.MenuId == 3220 && x.PermissionId == 3 && x.PermissionFlag).Count() > 0;
            ViewBag.canExport = role.SysRolePermission.Where(x => x.MenuId == 3220 && x.PermissionId == 4 && x.PermissionFlag).Count() > 0;
            List <TblKpt> lst = new List <TblKpt>();

            try
            {
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                var data = uow.db.TblKpt.AsQueryable();
                if (!CurrentUser.FlagAdminCalc)
                {
                    var staffs = db.CalcAccountStaff.Where(x => x.AccountId == CurrentUID).Select(x => x.StaffId).ToList();
                    if (staffs.Count() > 0)
                    {
                        data = data.Where(x => staffs.Contains(x.CreatedBy) || x.CreatedBy == CurrentUID);
                    }
                    else
                    {
                        data = data.Where(x => x.CreatedBy == CurrentUID);
                    }
                }
                int total = data.Count();
                WidgetPaginationModel Pagination = new WidgetPaginationModel("Index", "KPT", "")
                {
                    Page      = (page ?? 1),
                    Size      = (size ?? 10),
                    SearchCri = new Dictionary <string, dynamic>(),
                    SortExp   = "",
                    Total     = total
                };
                ViewBag.Pagination = Pagination;
                lst = data
                      .OrderByDescending(x => x.KptDate)
                      .ThenBy(x => x.ProjectName)
                      .Include(x => x.TblKptDetail)
                      .Skip((Pagination.Page - 1) * Pagination.Size)
                      .Take(Pagination.Size)
                      .ToList();
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage()
                };
                ViewBag.Alert = Alert;
            }
            return(View(lst));
        }
Пример #16
0
        public ActionResult Index(int?page, int?size, string msg, AlertMsgType?msgType,
                                  int year, int month, string src = "")
        {
            List <CalendarDayModel> data   = new List <CalendarDayModel>();
            List <TblSaleOrder>     lst    = new List <TblSaleOrder>();
            List <TblJobOrder>      joblst = new List <TblJobOrder>();

            try
            {
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                AccountPermission permission = GetPermission(CurrentUID);
                ViewData["optPermission"] = permission;
                DateTime firstDt = new DateTime(year, month, 1);
                ViewBag.FocusDate = firstDt;
                if (permission.TeamType == TeamType.Admin || permission.TeamType == TeamType.Sale)   //administrator of sale
                {
                    int total = uow.Modules.SaleOrder.Count(month, src);
                    lst = uow.Modules.SaleOrder.GetAll(1, -1, month, src, (permission.IsAdminTeam || permission.IsManager) ? 0 : CurrentUID);
                    #region Calculate first week
                    for (int i = firstDt.DayOfWeek.ToInt(); i > 0; i--)
                    {
                        CalendarDayModel day = new CalendarDayModel()
                        {
                            Date     = firstDt.AddDays(-i),
                            Jobs     = new List <TblSaleOrder>(),
                            TeamType = permission.TeamType
                        };
                        data.Add(day);
                    }
                    #endregion
                    int offset = data.Count;
                    for (int i = offset; i <= 42; i++)
                    {
                        CalendarDayModel day = new CalendarDayModel()
                        {
                            Date     = firstDt.AddDays(i - offset),
                            Jobs     = new List <TblSaleOrder>(),
                            TeamType = permission.TeamType
                        };
                        if (day.Date.Month == month)
                        {
                            var dayJobs = lst.Where(x =>
                                                    x.SaleOrderDate.HasValue &&
                                                    x.SaleOrderDate.Value.Date == day.Date.Date);
                            day.Jobs = dayJobs.Count() > 0 ? dayJobs.ToList() : new List <TblSaleOrder>();
                        }
                        data.Add(day);
                    }
                }
                else if (permission.TeamType == TeamType.Operation)  ///operation
                {
                    joblst = uow.Modules.JobOrder.GetAll(1, -1, month, src, (permission.IsAdminTeam) ? 0 : permission.TeamId);
                    #region Calculate first week
                    for (int i = firstDt.DayOfWeek.ToInt(); i > 0; i--)
                    {
                        CalendarDayModel day = new CalendarDayModel()
                        {
                            Date      = firstDt.AddDays(-i),
                            JobsOrder = new List <TblJobOrder>(),
                            TeamType  = permission.TeamType
                        };
                        data.Add(day);
                    }
                    #endregion
                    int offset = data.Count;
                    for (int i = offset; i <= 42; i++)
                    {
                        CalendarDayModel day = new CalendarDayModel()
                        {
                            Date      = firstDt.AddDays(i - offset),
                            JobsOrder = new List <TblJobOrder>(),
                            TeamType  = permission.TeamType
                        };
                        if (day.Date.Month == month)
                        {
                            var dayJobs = joblst.Where(x =>
                                                       x.StartDate.HasValue &&
                                                       x.StartDate.Value.Date == day.Date.Date
                                                       );
                            day.JobsOrder = dayJobs.Count() > 0 ? dayJobs.ToList() : new List <TblJobOrder>();
                        }
                        data.Add(day);
                    }
                }
                else
                {
                    #region Calculate first week
                    for (int i = firstDt.DayOfWeek.ToInt(); i > 0; i--)
                    {
                        CalendarDayModel day = new CalendarDayModel()
                        {
                            Date      = firstDt.AddDays(-i),
                            JobsOrder = new List <TblJobOrder>(),
                            TeamType  = permission.TeamType
                        };
                        data.Add(day);
                    }
                    #endregion
                    int offset = data.Count;
                    for (int i = offset; i <= 42; i++)
                    {
                        CalendarDayModel day = new CalendarDayModel()
                        {
                            Date = firstDt.AddDays(i - offset)
                        };
                        data.Add(day);
                    }
                }
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage()
                };
                ViewBag.Alert = Alert;
            }
            return(View(data));
        }
Пример #17
0
        public ActionResult Maps(int?page, int?size, string dateStart, string dateEnd, string msg, AlertMsgType?msgType)
        {
            DateTime?dtStart = dateStart.ParseDateNullable(DateFormat.ddMMyyyy);
            DateTime?dtEnd   = dateEnd.ParseDateNullable(DateFormat.ddMMyyyy);

            ViewData["GoogleMapsAPIKey"] = ConfigurationManager.AppSettings["GoogleMapsAPI"];
            SysRole role = CurrentUser.Role(3).Role();

            ViewBag.canWrite  = role.SysRolePermission.Where(x => x.MenuId == 3710 && x.PermissionId == 2 && x.PermissionFlag).Count() > 0;
            ViewBag.canDelete = role.SysRolePermission.Where(x => x.MenuId == 3710 && x.PermissionId == 3 && x.PermissionFlag).Count() > 0;
            ViewBag.canExport = role.SysRolePermission.Where(x => x.MenuId == 3710 && x.PermissionId == 4 && x.PermissionFlag).Count() > 0;
            List <TblKpt> lst = new List <TblKpt>();

            try
            {
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                var data = uow.db.TblKpt.AsQueryable();
                if (dtStart.HasValue)
                {
                    data = data.Where(x => DbFunctions.TruncateTime(x.CreatedDate) >= dtStart.Value);
                }
                if (dtEnd.HasValue)
                {
                    data = data.Where(x => DbFunctions.TruncateTime(x.CreatedDate) <= dtEnd.Value);
                }
                ViewData["dateStart"] = dtStart.ParseString(DateFormat.ddMMyyyy);
                ViewData["dateEnd"]   = dtEnd.ParseString(DateFormat.ddMMyyyy);
                int total = data.Count();
                WidgetPaginationModel Pagination = new WidgetPaginationModel("Maps", "Report", "")
                {
                    Page      = (page ?? 1),
                    Size      = (size ?? 10),
                    SearchCri = new Dictionary <string, dynamic>(),
                    SortExp   = "",
                    Total     = total
                };
                ViewBag.Pagination = Pagination;
                lst = data
                      .OrderByDescending(x => x.KptDate)
                      .ThenBy(x => x.ProjectName)
                      .Include(x => x.TblKptDetail)
                      .Skip((Pagination.Page - 1) * Pagination.Size)
                      .Take(Pagination.Size)
                      .ToList();
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage()
                };
                ViewBag.Alert = Alert;
            }
            return(View(lst));
        }
Пример #18
0
        public ActionResult Index(int?page, int?size, string dateStart, string dateEnd, string msg, AlertMsgType?msgType)
        {
            DateTime?         dtStart = dateStart.ParseDateNullable(DateFormat.ddMMyyyy);
            DateTime?         dtEnd   = dateEnd.ParseDateNullable(DateFormat.ddMMyyyy);
            List <TblCalLoad> lst     = new List <TblCalLoad>();

            try
            {
                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }
                var data = db.TblCalLoad.AsQueryable();
                if (dtStart.HasValue)
                {
                    data = data.Where(x => DbFunctions.TruncateTime(x.CreatedDate) >= dtStart.Value);
                }
                if (dtEnd.HasValue)
                {
                    data = data.Where(x => DbFunctions.TruncateTime(x.CreatedDate) <= dtEnd.Value);
                }
                int total = data.Count();
                ViewData["dateStart"] = dtStart.ParseString(DateFormat.ddMMyyyy);
                ViewData["dateEnd"]   = dtEnd.ParseString(DateFormat.ddMMyyyy);
                WidgetPaginationModel Pagination = new WidgetPaginationModel("Index", "Report", "")
                {
                    Page      = (page ?? 1),
                    Size      = (size ?? 10),
                    SearchCri = new Dictionary <string, dynamic>(),
                    SortExp   = "",
                    Total     = total
                };
                ViewBag.Pagination = Pagination;
                lst = (from d in data
                       join m in db.TblPile on d.ModelId equals m.PileId
                       orderby
                       d.CreatedDate descending
                       , m.PileName ascending
                       , d.InputC ascending
                       select d)
                      .Skip((Pagination.Page - 1) * Pagination.Size)
                      .Take(Pagination.Size)
                      .ToList();
            }
            catch (Exception ex)
            {
                WidgetAlertModel Alert = new WidgetAlertModel()
                {
                    Type    = AlertMsgType.Danger,
                    Message = ex.GetMessage()
                };
                ViewBag.Alert = Alert;
            }
            return(View(lst));
        }
Пример #19
0
        private ActionResult ViewDetail(TblSaleOrder ob, string msg, AlertMsgType?msgType)
        {
            List <TblQuotation> quotationList = null;

            try
            {
                if (ob == null)
                {
                    throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง");
                }

                if (!string.IsNullOrWhiteSpace(msg))
                {
                    WidgetAlertModel alert = new WidgetAlertModel()
                    {
                        Message = msg
                    };
                    if (msgType.HasValue)
                    {
                        alert.Type = msgType.Value;
                    }
                    ViewBag.Alert = alert;
                }

                quotationList = uow.Modules.Quotation.GetQuatationNotSale()
                                .Where(q => q.StatusId == 3)
                                .ToList();
                if (quotationList == null)
                {
                    quotationList = new List <TblQuotation>();
                }

                AccountPermission permission = new AccountPermission();
                permission = GetPermissionSale(CurrentUser.AccountId, ob.CreatedBy.HasValue ? ob.CreatedBy.Value : 0);

                quotationList.Add(uow.Modules.Quotation.Get(ob.QuotationNo));
                ViewData["optSoDetail"]        = uow.Modules.SaleOrderDetail.Gets(ob.SaleOrderId);
                ViewData["optQuotation"]       = quotationList;
                ViewData["optCustomer"]        = uow.Modules.Customer.GetAllAddress();
                ViewData["optCustomerAddress"] = uow.Modules.CustomerAddress.Gets();
                ViewData["optProduct"]         = uow.Modules.Product.Gets("0");
                ViewData["optContact"]         = uow.Modules.CustomerContact.Gets();
                ViewData["optEmployee"]        = uow.Modules.Employee.Gets();
                ViewData["optPayment"]         = uow.Modules.PaymentCondition.Gets();
                ViewData["optAttachment"]      = uow.Modules.SaleOrderAttachment.Gets(ob.SaleOrderId);
                ViewData["optTeam"]            = uow.Modules.TeamOperation.Gets();
                ViewData["userAccount"]        = CurrentUser;
                ViewData["optPermission"]      = permission;
                ViewData["optWareHouse"]       = uow.Modules.WareHouse.Gets();
                return(View(ob));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", MVCController, new
                {
                    area = MVCArea,
                    msg = ex.GetMessage(),
                    msgType = AlertMsgType.Danger
                }));
            }
        }