Exemple #1
0
 public List <SalaryViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Salary.Select(s => new SalaryViewModel()
         {
             SaID    = s.SaID,
             SaLevel = s.SaLevel,
             SaStep  = s.SaStep,
             SaRate  = s.SaRate
         }).OrderBy(x => x.SaLevel).ToList();
         return(list);
     }
 }
Exemple #2
0
 public ManPowerViewModel GetDetailByMp(int mpid)
 {
     using (SATEntities db = new SATEntities())
     {
         ManPowerViewModel model = new ManPowerViewModel();
         var data = db.vw_Man_Power.Where(m => m.MpID == mpid).FirstOrDefault();
         if (data != null)
         {
             model.BelongTo = data.DivName + " / " + data.DepName + " / " + data.SecName;
             model.FullName = data.FullNameTh;
         }
         return(model);
     }
 }
Exemple #3
0
 public DepartmentViewModel GetByID(int id)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_Department.Where(x => x.DepID == id).FirstOrDefault();
         DepartmentViewModel model = new Models.DepartmentViewModel();
         model.DepID     = data.DepID;
         model.DepName   = data.DepName;
         model.DepStatus = (bool)data.DepStatus;
         model.Status    = data.DepStatus == true ? EnumType.StatusName.Active : EnumType.StatusName.NotActive;
         model.DivID     = data.DivID;
         return(model);
     }
 }
Exemple #4
0
 public SysConfigViewModel GetByKeyName(string keyname)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_SysConfig.Where(x => x.KeyName == keyname).FirstOrDefault();
         SysConfigViewModel model = new Models.SysConfigViewModel();
         model.KeyName    = data.KeyName;
         model.KeyValue   = data.KeyValue;
         model.KeyDesc    = data.KeyDesc;
         model.ModifyBy   = UtilityService.User.UserID;
         model.ModifyDate = data.ModifyDate;
         return(model);
     }
 }
 public CapabilityViewModel GetByID(int id)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_Capability.Where(x => x.CapID == id).FirstOrDefault();
         CapabilityViewModel model = new Models.CapabilityViewModel();
         model.CapID   = data.CapID;
         model.CapYear = data.CapYear;
         model.CapTID  = data.CapTID;
         model.CapGID  = data.CapGID;
         model.CapGTID = data.CapGTID;
         return(model);
     }
 }
Exemple #6
0
 public List <InsigniaViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Insignia.Select(s => new InsigniaViewModel()
         {
             InsID        = s.InsID,
             InsFullName  = s.InsFullName,
             InsShortName = s.InsShortName,
             InsStatus    = s.InsStatus
         }).OrderBy(x => x.InsFullName).ToList();
         return(list);
     }
 }
 public List <CapabilityViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Capability.Select(s => new CapabilityViewModel()
         {
             CapID   = s.CapID,
             CapYear = s.CapYear,
             CapTID  = s.CapTID,
             CapGID  = s.CapGID,
         }).OrderBy(x => x.CapYear).ToList();
         return(list);
     }
 }
 public PositionViewModel GetByID(int id)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_Position.Where(x => x.PoID == id).FirstOrDefault();
         PositionViewModel model = new Models.PositionViewModel();
         model.PoID     = data.PoID;
         model.PoCode   = data.PoCode;
         model.PoName   = data.PoName;
         model.PoStatus = data.PoStatus;
         model.Status   = data.PoStatus == true ? EnumType.StatusName.Active : EnumType.StatusName.NotActive;
         return(model);
     }
 }
Exemple #9
0
        public List <SysConfigViewModel> GetAll()
        {
            using (SATEntities db = new SATEntities())
            {
                var data = db.tb_SysConfig.Where(w => w.Visible == true).Select(s => new SysConfigViewModel()
                {
                    KeyName  = s.KeyName,
                    KeyValue = s.KeyValue,
                    KeyDesc  = s.KeyDesc
                }).ToList();

                return(data);
            }
        }
Exemple #10
0
 public List <EducationViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Education.Select(s => new EducationViewModel()
         {
             EduID     = s.EduID,
             EduCode   = s.EduCode,
             EduName   = s.EduName,
             EduStatus = s.EduStatus,
         }).OrderBy(x => x.EduName).ToList();
         return(list);
     }
 }
Exemple #11
0
 public List <CountryViewModel> GetCountry()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Country.Select(s => new CountryViewModel()
         {
             CountryID   = s.CountryID,
             CountryName = s.CountryName,
         })
                    .OrderBy(o => o.CountryName)
                    .ToList();
         return(list);
     }
 }
Exemple #12
0
 public List <SubDistrictViewModel> GetSubDistrict()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_SubDistrict.Select(s => new SubDistrictViewModel()
         {
             SubDistrictID   = s.SubDistrictID,
             SubDistrictName = s.SubDistrictName,
             DistrictID      = s.DistrictID,
             ProvinceID      = s.ProvinceID,
         }).ToList();
         return(list);
     }
 }
Exemple #13
0
 public InsigniaViewModel GetByID(int id)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_Insignia.Where(x => x.InsID == id).FirstOrDefault();
         InsigniaViewModel model = new Models.InsigniaViewModel();
         model.InsID        = data.InsID;
         model.InsFullName  = data.InsFullName;
         model.InsShortName = data.InsShortName;
         model.InsStatus    = data.InsStatus;
         model.Status       = data.InsStatus == true ? EnumType.StatusName.Active : EnumType.StatusName.NotActive;
         return(model);
     }
 }
Exemple #14
0
        public void SetInforHomepage(SATEntities db)
        {
            var categories = db.Categories.Where(t => t.ParentId == 1).OrderBy(t => t.OrderNumber).ToList();

            ViewBag.Categories = categories;
            ViewBag.Facebook   = db.Settings.FirstOrDefault(t => t.Id == 2).Value;
            ViewBag.Youtube    = db.Settings.FirstOrDefault(t => t.Id == 3).Value;
            ViewBag.Linked     = db.Settings.FirstOrDefault(t => t.Id == 6).Value;
            ViewBag.Gplus      = db.Settings.FirstOrDefault(t => t.Id == 5).Value;
            ViewBag.Instagram  = db.Settings.FirstOrDefault(t => t.Id == 4).Value;

            ViewBag.Hotline = db.Settings.FirstOrDefault(t => t.Id == 1).Value;
            ViewBag.Address = db.Settings.FirstOrDefault(t => t.Key == "address").Value;
            ViewBag.Phone   = db.Settings.FirstOrDefault(t => t.Key.Equals("phone")).Value;
        }
Exemple #15
0
 public List <TitleViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Title.Select(s => new TitleViewModel()
         {
             TiID        = s.TiID,
             TiFullName  = s.TiFullName,
             TiShortName = s.TiShortName,
             TiStatus    = s.TiStatus,
             SexID       = s.SexID,
         }).OrderBy(x => x.TiFullName).ToList();
         return(list);
     }
 }
Exemple #16
0
 public decimal GetSalary(int level, decimal step)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_Salary.Where(m => m.SaLevel == level && m.SaStep == step).FirstOrDefault();
         if (data != null)
         {
             return(Convert.ToDecimal(data.SaRate));
         }
         else
         {
             return(0);
         }
     }
 }
 public List <PositionViewModel> GetByType(int?typeid)
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Position.Where(w => w.TypeID == typeid).Select(s => new PositionViewModel()
         {
             PoID     = s.PoID,
             PoCode   = s.PoCode,
             PoName   = s.PoName,
             PoStatus = s.PoStatus,
             TypeID   = s.TypeID
         }).OrderBy(x => x.PoCode).ToList();
         return(list);
     }
 }
Exemple #18
0
 public List <HolidayViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Holiday.Select(s => new HolidayViewModel()
         {
             HolID          = s.HolID,
             HolDate        = s.HolDate,
             HolDescription = s.HolDescription,
             HolYear        = s.HolDate.Value.Year,
             HolDateText    = s.HolDate.Value.ToString("dd/MM/yyyy"),
         }).OrderBy(x => x.HolDescription).ToList();
         return(list);
     }
 }
Exemple #19
0
 public SectionViewModel GetByID(int id)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_Section.Where(x => x.SecID == id).FirstOrDefault();
         SectionViewModel model = new Models.SectionViewModel();
         model.SecID     = data.SecID;
         model.SecName   = data.SecName;
         model.SecStatus = data.SecStatus;
         model.DivID     = data.DivID;
         model.DepID     = data.DepID;
         model.Status    = data.SecStatus == true ? EnumType.StatusName.Active : EnumType.StatusName.NotActive;
         return(model);
     }
 }
Exemple #20
0
 public TitleViewModel GetByID(int id)
 {
     using (SATEntities db = new SATEntities())
     {
         var            data  = db.tb_Title.Where(x => x.TiID == id).FirstOrDefault();
         TitleViewModel model = new Models.TitleViewModel();
         model.TiID        = data.TiID;
         model.TiFullName  = data.TiFullName;
         model.TiShortName = data.TiShortName;
         model.TiStatus    = data.TiStatus;
         model.SexID       = data.SexID;
         model.Status      = data.TiStatus == true ? EnumType.StatusName.Active : EnumType.StatusName.NotActive;
         return(model);
     }
 }
Exemple #21
0
 public List <DepartmentViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.vw_Department.Select(s => new DepartmentViewModel()
         {
             DepID     = s.DepID,
             DepName   = s.DepName,
             DepStatus = (bool)s.DepStatus,
             DivID     = s.DivID,
             DivName   = s.DivName
         }).OrderBy(x => x.DepName).ToList();
         return(list);
     }
 }
Exemple #22
0
        public HolidayResult GetPage(string filter, int?draw, int?initialPage, int?pageSize, string sortDir, string sortBy)
        {
            using (SATEntities db = new SATEntities())
            {
                var data = db.tb_Holiday.ToList();

                int recordsTotal = data.Count();

                if (!string.IsNullOrEmpty(filter))
                {
                    data = data.Where(x => x.HolDescription.Contains(filter)).ToList();
                }

                int recordsFiltered = data.Count();

                switch (sortBy)
                {
                case "HolDescription":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.HolDescription).ToList() : data.OrderByDescending(x => x.HolDescription).ToList();
                    break;

                case "HolDateText":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.HolDate).ToList() : data.OrderByDescending(x => x.HolDate).ToList();
                    break;
                }

                int start  = initialPage.HasValue ? (int)initialPage / (int)pageSize : 0;
                int length = pageSize ?? 10;

                var list = data.Select((s, i) => new HolidayViewModel()
                {
                    RowNumber      = ++i,
                    HolID          = s.HolID,
                    HolDate        = s.HolDate,
                    HolDescription = s.HolDescription,
                    HolYear        = s.HolDate.Value.Year,
                    HolDateText    = s.HolDate.Value.ToString("dd/MM/yyyy"),
                }).Skip(start * length).Take(length).ToList();

                HolidayResult result = new HolidayResult();
                result.draw            = draw ?? 0;
                result.recordsTotal    = recordsTotal;
                result.recordsFiltered = recordsFiltered;
                result.data            = list;

                return(result);
            }
        }
Exemple #23
0
 public List <CapabilityDetailViewModel> GetByCap(int capis)
 {
     using (SATEntities db = new SATEntities())
     {
         var data = db.tb_Capability_Detail.Where(x => x.CapID == capis).Select(s => new CapabilityDetailViewModel
         {
             CapDID   = s.CapDID,
             CapDName = s.CapDName,
             CapDDesc = s.CapDDesc,
             CapID    = s.CapID,
             Score1   = s.Score1,
             Score2   = s.Score2,
         }).ToList();
         return(data);
     }
 }
Exemple #24
0
        public RoleMenuViewModel MenuRole(int roleid)
        {
            using (SATEntities db = new SATEntities())
            {
                RoleMenuViewModel model = new RoleMenuViewModel();

                var role = GetRoleByID(roleid);
                model.RoleID             = role.RoleID;
                model.RoleName           = role.RoleName;
                model.RoleDesc           = role.RoleDesc;
                model.ListRoleMenu       = MenuByRole(roleid);
                model.ListRoleMenuTab    = MenuTabByRole(roleid);
                model.ListRoleMenuReport = MenuReportByRole(roleid);
                return(model);
            }
        }
Exemple #25
0
        public MajorResult GetPage(string filter, int?draw, int?initialPage, int?pageSize, string sortDir, string sortBy)
        {
            using (SATEntities db = new SATEntities())
            {
                var data = db.tb_Major.ToList();

                int recordsTotal = data.Count();

                if (!string.IsNullOrEmpty(filter))
                {
                    data = data.Where(x => x.MajName.Contains(filter)).ToList();
                }

                int recordsFiltered = data.Count();

                switch (sortBy)
                {
                case "MajName":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.MajName).ToList() : data.OrderByDescending(x => x.MajName).ToList();
                    break;

                case "Status":
                    data = (sortDir == "asc") ? data.OrderBy(x => x.MajStatus).ToList() : data.OrderByDescending(x => x.MajStatus).ToList();
                    break;
                }

                int start  = initialPage.HasValue ? (int)initialPage / (int)pageSize : 0;
                int length = pageSize ?? 10;

                var list = data.Select((s, i) => new MajorViewModel()
                {
                    RowNumber = ++i,
                    MajID     = s.MajID,
                    MajName   = s.MajName,
                    MajStatus = s.MajStatus,
                    Status    = s.MajStatus == true ? EnumType.StatusName.Active : EnumType.StatusName.NotActive
                }).Skip(start * length).Take(length).ToList();

                MajorResult result = new MajorResult();
                result.draw            = draw ?? 0;
                result.recordsTotal    = recordsTotal;
                result.recordsFiltered = recordsFiltered;
                result.data            = list;

                return(result);
            }
        }
Exemple #26
0
        public ActionResult Edit(int id)
        {
            using (var db = new SATEntities())
            {
                ViewBag.EditQuestion = true;
                var hasInput = true;
                var textType = new SelectListItem()
                {
                    Value = "1", Text = "Nhập vào"
                };
                var choiceType = new SelectListItem()
                {
                    Value = "0", Text = "Chọn câu", Disabled = hasInput ? true : false
                };
                ViewBag.AnswerType = new SelectList(new List <SelectListItem>()
                {
                    choiceType, textType
                }, "Value", "Text", hasInput ? "1" : "0");
                var questionEntity = db.SATQuestions.Find(id);


                var model = questionEntity.Map <QuestionEditViewModel>();
                model.Answers = new QuestionEditViewModel(id).Answers;

                ViewBag.FormValue = JsonConvert.SerializeObject(model, new JsonSerializerSettings {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });
                var listType = new SelectList(db.SATTypes.ToList(), "TypeID", "TypeName", questionEntity.TypeID);
                ViewBag.Type = listType;
                List <SelectListItem> listCalc = UseCalcSelectList();
                //ViewBag.UseCalc = new SelectList(listCalc, "Value", "Text", questionEntity.UserCalculator);
                var examContentID   = questionEntity.ExamContentID != null ? questionEntity.ExamContentID.Value : 0;
                var listExamContent = new ExamContentSelectList().GetExamContentSelectList(examContentID);
                ViewBag.SelectedID    = examContentID;
                ViewBag.ExamContentID = listExamContent;
                if (model.Answers?.Count > 1)
                {
                    ViewBag.IsInputAnswer = false;
                }
                else
                {
                    ViewBag.IsInputAnswer = true;
                }

                return(View("EditWithAnswer", model));
            }
        }
Exemple #27
0
        public DisciplineResult GetPage(string filter, int?draw, int?initialPage, int?pageSize, string sortDir, string sortBy)
        {
            using (SATEntities db = new SATEntities())
            {
                DisciplineResult result = new DisciplineResult();

                try
                {
                    var data = db.tb_Discipline.ToList();

                    int recordsTotal = data.Count();

                    if (!string.IsNullOrEmpty(filter))
                    {
                        data = data.Where(x => x.DisName.Contains(filter)).ToList();
                    }

                    int recordsFiltered = data.Count();

                    switch (sortBy)
                    {
                    case "DisName":
                        data = (sortDir == "asc") ? data.OrderBy(x => x.DisName).ToList() : data.OrderByDescending(x => x.DisName).ToList();
                        break;
                    }

                    int start  = initialPage.HasValue ? (int)initialPage / (int)pageSize : 0;
                    int length = pageSize ?? 10;

                    var list = data.Select((s, i) => new DisciplineViewModel()
                    {
                        RowNumber = i + 1,
                        DisID     = s.DisID,
                        DisName   = s.DisName,
                    }).Skip(start * length).Take(length).ToList();

                    result.draw            = draw ?? 0;
                    result.recordsTotal    = recordsTotal;
                    result.recordsFiltered = recordsFiltered;
                    result.data            = list;
                }
                catch (Exception)
                {
                }
                return(result);
            }
        }
Exemple #28
0
 public List <SectionViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.vw_Section.Select(m => new SectionViewModel()
         {
             SecID     = m.SecID,
             SecName   = m.SecName,
             SecStatus = m.SecStatus,
             DivID     = (int)m.DivID,
             DivName   = m.DivName,
             DepID     = (int)m.DepID,
             DepName   = m.DepName,
         }).OrderBy(x => x.SecName).ToList();
         return(list);
     }
 }
Exemple #29
0
 public ResponseData SubmitByEntity(List <CapabilityDetailViewModel> newdata)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             foreach (var item in newdata)
             {
                 if (item.CapDID != 0)
                 {
                     var data = db.tb_Capability_Detail.Single(x => x.CapDID == item.CapDID);
                     data.CapDID     = item.CapDID;
                     data.CapDName   = item.CapDName;
                     data.CapDDesc   = item.CapDDesc;
                     data.CapID      = item.CapID;
                     data.Score1     = item.Score1;
                     data.Score2     = item.Score2;
                     data.ModifyBy   = UtilityService.User.UserID;
                     data.ModifyDate = DateTime.Now;
                     db.SaveChanges();
                 }
                 else
                 {
                     tb_Capability_Detail model = new tb_Capability_Detail();
                     model.CapDID     = item.CapDID;
                     model.CapDName   = item.CapDName;
                     model.CapDDesc   = item.CapDDesc;
                     model.CapID      = item.CapID;
                     model.Score1     = item.Score1;
                     model.Score2     = item.Score2;
                     model.CreateBy   = UtilityService.User.UserID;
                     model.CreateDate = DateTime.Now;
                     model.ModifyBy   = UtilityService.User.UserID;
                     model.ModifyDate = DateTime.Now;
                     db.tb_Capability_Detail.Add(model);
                     db.SaveChanges();
                 }
             }
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Exemple #30
0
 public List <LeaveTypeViewModel> GetAll()
 {
     using (SATEntities db = new SATEntities())
     {
         var list = db.tb_Leave_Type.Select(s => new LeaveTypeViewModel()
         {
             LevID            = s.LevID,
             LevYear          = s.LevYear,
             LevName          = s.LevName,
             LevStartDateText = s.LevStartDate.Value.ToString("dd/MM/yyyy"),
             LevEndDateText   = s.LevEndDate.Value.ToString("dd/MM/yyyy"),
             LevMax           = s.LevMax,
             LevStatus        = s.LevStatus,
             SexID            = s.SexID,
         }).OrderBy(x => x.LevName).ToList();
         return(list);
     }
 }