public ActionResult GetChuong(string key, int id) { try { string sWhere = (AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) ? " 1=1 " : " a.CreatedBy =" + WebSecurity.CurrentUserId; sWhere += " and a.ParentId=" + id; sWhere += " and a.Section like '%" + key + "%'"; string sSort = "a.Orders DESC"; var modelList = new SysAdminAction <Ex_Question>().List(sWhere, sSort, 0, 100); //Check after deleted last item in page . Redirect page close have value smaller if (Request.IsAjaxRequest()) { return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success, Data = modelList })); } } catch (Exception exception) { Ultity.TFunction.WriteToLog(exception); return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); }
public ActionResult Index() { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); ViewBag.Accept = AuthorizeUser.IsAction(Ultity.Constant.Accept); ViewBag.UsedStateAdd = Ultity.TFunction.GetUsedStateSelected(Ultity.Constant.Active); //ViewBag.TypeList = new SysAdminAction<Cms_ClassVideo>().List("a.UsedState=1 and a.Type=" + Ultity.Constant.Video, "a.Orders asc", 0, 100); string[] str = { Constant.UsedState_Delete, Constant.UsedState_NotActive }; var itemsList = new List <SelectListItem>(); for (int i = -1; i < str.Length - 1; i++) { bool isSelected = false; if (i == Constant.NotActive) { isSelected = true; } var selectListItem = new SelectListItem { Text = str[i + 1], Value = CommonHelper.Convert.ConvertToString(i), Selected = isSelected }; itemsList.Add(selectListItem); } ViewBag.UsedState = itemsList; ViewBag.Grade = new SysAdminAction <Ex_CategoryValue>().List("a.CatCode='KHOI'", "a.Orders desc", 0, 100); return(View()); }
public ActionResult GetChuong(string key, string code) { try { string sWhere = (AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) ? " WHERE 1=1 " : " WHERE a.CreatedBy =" + WebSecurity.CurrentUserId; sWhere += " and a.Section like '%" + key + "%'"; sWhere += " and a.ExamCode = '" + code.Trim() + "'"; string sSort = " ORDER BY a.Orders DESC"; var modelList = new Ex_ExamConfigAction().GetExamConfig(sWhere, sSort); //Check after deleted last item in page . Redirect page close have value smaller if (Request.IsAjaxRequest()) { return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success, Data = modelList })); } } catch (Exception exception) { Ultity.TFunction.WriteToLog(exception); return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); }
public ActionResult Delete(string id) { try { if (!string.IsNullOrEmpty(id)) { string sWhere = " Id IN (" + id.Trim() + ") "; string sSet = "UsedState = " + Ultity.Constant.Request_Delete; if (!AuthorizeUser.IsHost()) { new SysAdminAction <Ex_Category>().Updates(sSet, sWhere); return(Json(new { status = "success", Message = Ultity.Constant.Change_Delete_Success })); } else { new SysAdminAction <Ex_Category>().Deletes(sWhere); return(Json(new { status = "success", Message = Ultity.Constant.Delete_Success })); } //Trigger auto to delete table related } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } catch (Exception exception) { return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } }
public ActionResult GetData(int?page, int?pageSize, string key, string grade, int subjectId, string exam, int sectionId) { try { var objRef = new object[5]; int currentPageIndex = page.HasValue ? page.Value - 1 : 0; if (currentPageIndex < 0) { currentPageIndex = 0; } pageSize = rowInPage; string sWhere = (AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) ? " 1=1 " : " a.CreatedBy =" + WebSecurity.CurrentUserId; if (!string.IsNullOrEmpty(key)) { key = key.Trim(); ViewBag.Search = key; sWhere += "and ( a.QuestionContent like N'%" + key + "%' or dbo.ConvertToNoSigned(a.QuestionContent) like dbo.ConvertToNoSigned(N'%" + key + "%')) "; } if (!string.IsNullOrEmpty(grade)) { sWhere += " and a.Grade ='" + grade.Trim() + "'"; } if (subjectId > 0) { sWhere += " and a.SubjectId =" + subjectId + ""; } if (!string.IsNullOrEmpty(exam)) { sWhere += " and a.ExamId ='" + exam.Trim() + "'"; } if (sectionId > 0) { sWhere += " and a.SectionId =" + sectionId + ""; } string sSort = "a.CreatedDate DESC"; objRef[0] = sWhere; objRef[1] = sSort; objRef[2] = currentPageIndex; objRef[3] = pageSize; objRef[4] = 0; var modelList = _sysAction.List(ref objRef); int totalRow = CommonHelper.Convert.ConvertToInt32(objRef[4]); //Check after deleted last item in page . Redirect page close have value smaller if (Request.IsAjaxRequest()) { return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success, Data = modelList, TotalPage = totalRow, CurrentPage = currentPageIndex, PageSize = pageSize })); } } catch (Exception exception) { Ultity.TFunction.WriteToLog(exception); return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); }
public ActionResult Index() { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); ViewBag.UsedStateAdd = Ultity.TFunction.GetUsedStateSelected(Ultity.Constant.Active); ViewBag.UsedState = Ultity.TFunction.GetAllUsedStateSelected(Ultity.Constant.All); return(View()); }
// GET: Admin/ReportClass public ActionResult Index() { bool checkRole = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); var lstUser = new List <SysUser>(); var lstUserTeacher = new SysGroupAction().GetUserInGroup(20, string.Empty); if (checkRole) { var admin = new SysAdminAction <SysUser>().GetById(Ultity.Constant.userIdAdmin); lstUser.Add(new SysUser() { UserId = admin.UserId, UserName = admin.UserName }); lstUserTeacher.ForEach(x => { lstUser.Add(new SysUser() { UserId = x.UserId, UserName = x.UserName }); }); } else { var user = new SysAdminAction <SysUser>().GetById(WebSecurity.CurrentUserId); lstUser.Add(new SysUser() { UserId = user.UserId, UserName = user.UserName }); } var lstClass = new List <Cms_Class>(); var lstExam = new List <Ex_Exam>(); if (checkRole) { lstClass = new SysAdminAction <Cms_Class>().List("", "a.CreatedDate desc", 0, 100); lstExam = new SysAdminAction <Ex_Exam>().List("", "a.CreatedDate desc", 0, 100); } else { lstClass = new SysAdminAction <Cms_Class>().List("a.CreatedBy=" + WebSecurity.CurrentUserId, "a.CreatedDate desc", 0, 100); lstExam = new SysAdminAction <Ex_Exam>().List("a.CreatedBy=" + WebSecurity.CurrentUserId, "a.CreatedDate desc", 0, 100); } ViewBag.LstClass = lstClass; ViewBag.LstExam = lstExam; ViewBag.StartDate = DateTime.Now.ToString("dd/MM/yyy 00:00"); ViewBag.EndDate = DateTime.Now.ToString("dd/MM/yyy 23:59"); ViewBag.ListUser = lstUser; ViewBag.Host = checkRole; return(View()); }
public ActionResult Index() { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); ViewBag.UsedStateAdd = Ultity.TFunction.GetUsedStateSelected(Ultity.Constant.Active); ViewBag.UsedState = Ultity.TFunction.GetAllUsedStateSelected(Ultity.Constant.All); //ViewBag.TypeList = new SysAdminAction<Cms_ClassVideo>().List("a.UsedState=1 and a.Type=" + Ultity.Constant.Video, "a.Orders asc", 0, 100); return(View()); }
public ActionResult GetData(int?page, int?pageSize, string key, int?sort, string usedState, string subjectId) { try { var objRef = new object[5]; int currentPageIndex = page.HasValue ? page.Value - 1 : 0; if (currentPageIndex < 0) { currentPageIndex = 0; } pageSize = 100; string sWhere = (AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) ? " 1=1 " : " a.CreatedBy =" + WebSecurity.CurrentUserId; if (!string.IsNullOrEmpty(key)) { key = key.Trim(); ViewBag.Search = key; sWhere += "and ( a.Name like N'%" + key + "%' or dbo.ConvertToNoSigned(a.Name) like dbo.ConvertToNoSigned(N'%" + key + "%')) "; } if (!string.IsNullOrEmpty(usedState)) { if (!usedState.Equals(Ultity.Constant.All.ToString())) { ViewBag.UsedState = Ultity.TFunction.GetAllUsedStateSelected(CommonHelper.Convert.ConvertToInt32(usedState)); sWhere = string.IsNullOrEmpty(sWhere) ? " a.UsedState=" + usedState + "" : (sWhere + " AND a.UsedState=" + usedState + " "); } } if (!string.IsNullOrEmpty(subjectId)) { sWhere = string.IsNullOrEmpty(sWhere) ? " a.SubjectId=" + subjectId + "" : (sWhere + " AND a.SubjectId=" + subjectId + " "); } string sSort = "a.CreatedDate DESC"; objRef[0] = sWhere; objRef[1] = sSort; objRef[2] = currentPageIndex; objRef[3] = pageSize; objRef[4] = 0; var modelList = _sysAction.List(ref objRef); int totalRow = CommonHelper.Convert.ConvertToInt32(objRef[4]); //Check after deleted last item in page . Redirect page close have value smaller if (Request.IsAjaxRequest()) { return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success, Data = modelList, TotalPage = totalRow, CurrentPage = currentPageIndex, PageSize = pageSize })); } } catch (Exception exception) { Ultity.TFunction.WriteToLog(exception); return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); }
public ActionResult Index() { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); var model = new CmsIntroduce(); var list = new SysAdminAction <CmsIntroduce>().List(string.Empty, string.Empty, 0, 1); if (list.Count > 0) { model = list[0]; } return(View(model)); }
public ActionResult PheDuyetRutTien(string ids) { if (AuthorizeUser.IsHost()) { var model = new SysAdminAction <Cms_HistoryPayment>().GetByGuidId(ids); new SysAdminAction <SysUser>().Updates("BCoin=BCoin-" + model.BCoin, "UserId=" + model.FromUser); new SysAdminAction <Cms_HistoryPayment>().Updates("Summary=N'" + Ultity.Constant.RutTien + "' , IsActive=1", "IdGuid='" + ids + "'"); #region Gửi mail thông báo giao dịch thành công var modelEmail = new SysUserAction().GetById(model.FromUser); Models.THelper.SendMail(modelEmail.Email, modelEmail.FullName, String.Format("{0:0,0}", model.BCoin), "Rút tiền"); #endregion } return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success })); }
public ActionResult Index(int?cauhoi) { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); ViewBag.UsedStateAdd = Ultity.TFunction.GetUsedStateSelected(Ultity.Constant.Active); //ViewBag.UsedState = Ultity.TFunction.GetAllUsedStateSelected(Ultity.Constant.All); ViewBag.Grade = new SysAdminAction <Ex_CategoryValue>().List("a.CatCode='KHOI'", "", 0, 100); ViewBag.DoKho = new SysAdminAction <Ex_CategoryValue>().List("a.CatCode='DK'", "", 0, 100); return(View()); }
public ActionResult Index() { string sql = string.Empty; string sWhere = " 1=1 "; if (!AuthorizeUser.IsHost()) { sWhere += " AND CreatedBy=" + WebSecurity.CurrentUserId; } #region + Lấy thông tin Dashboard sql += " SELECT COUNT(*) AS TotalClass INTO #temp1 FROM Cms_Class WHERE " + sWhere; sql += " SELECT COUNT(*) AS TotalExam INTO #temp2 FROM Ex_Exam WHERE " + sWhere; sql += " SELECT COUNT(*) AS TotalTeacher INTO #temp3 FROM SysGroupUser"; sql += " WHERE GroupId = 20"; if (AuthorizeUser.IsHost()) { sql += " SELECT COUNT(*) AS TotalStudent INTO #temp4"; sql += " FROM SysGroupUser WHERE GroupId = 21"; } else { sql += " SELECT COUNT(*) AS TotalStudent INTO #temp4 FROM Cms_ClassStudent WHERE ClassId in(SELECT Id FROM Cms_Class WHERE " + sWhere + ")"; } if (AuthorizeUser.IsHost()) { sql += " SELECT COUNT(*) AS TotalVideo INTO #temp5 FROM Cms_ClassVideo"; } else { sql += " SELECT COUNT(*) AS TotalVideo INTO #temp5 FROM Cms_ClassVideo WHERE ClassId in(SELECT Id FROM Cms_Class WHERE " + sWhere + ")"; } sql += " SELECT TotalClass,TotalExam,TotalTeacher,TotalStudent,TotalVideo"; sql += " FROM #temp1,#temp2,#temp3,#temp4,#temp5"; sql += " DROP TABLE #temp1, #temp2, #temp3, #temp4, #temp5"; var totalClass = SqlHelper.ExecuteList <TotalInfoWebsite>(SqlConnection, CommandType.Text, sql); if (totalClass.Count > 0) { ViewBag.TotalInfoWebsite = totalClass[0]; } else { ViewBag.TotalInfoWebsite = new TotalInfoWebsite(); } #endregion ViewBag.Host = AuthorizeUser.IsHost(); int id = WebSecurity.CurrentUserId; return(View()); }
public ActionResult Delete(string id) { try { if (!string.IsNullOrEmpty(id)) { if (Request.IsAjaxRequest()) { string sWhere = " UserId IN (" + id.Trim() + ") "; string sSet = "UsedState = " + Ultity.Constant.Request_Delete; string tableName = "SysUser"; if (!AuthorizeUser.IsHost()) { new SysAdminAction <SysUser>().Updates(sSet, sWhere); return(Json(new { status = "success", Message = Ultity.Constant.Change_Delete_Success })); } else { if (id.Contains(",")) { var idList = id.Split(','); foreach (var item in idList) { var model = _sysAction.GetById(CommonHelper.Convert.ConvertToInt32(item)); ((SimpleMembershipProvider)Membership.Provider).DeleteUser(model.UserName, true); new SysAdminAction <SysUser>().Deletes("UserId =" + item); } } else { var model = _sysAction.GetById(CommonHelper.Convert.ConvertToInt32(id)); ((SimpleMembershipProvider)Membership.Provider).DeleteUser(model.UserName, true); new SysAdminAction <SysUser>().Deletes(sWhere); } return(Json(new { status = "success", Message = Ultity.Constant.Delete_Success })); } //Trigger auto to delete table related } } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } catch (Exception exception) { return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } }
public ActionResult Index() { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); if (ViewBag.Host) { ViewBag.UsedStateAdd = Ultity.TFunction.GetUsedStateSelected(Ultity.Constant.Active); } else { ViewBag.UsedStateAdd = Ultity.TFunction.GetAllUsedStateSelectedNotAdmin(Ultity.Constant.Active); } ViewBag.UsedState = Ultity.TFunction.GetAllUsedStateSelected(Ultity.Constant.All); #region Danh sách môn học var lstSubeject = new SysAdminAction <Ex_Subject>().List("a.UsedState=1", "a.Orders desc", 0, 100); var itemsListSearch = new List <SelectListItem>(); var itemsListEdit = new List <SelectListItem>(); var selectListItemAll = new SelectListItem { Text = "Tất cả", Value = "", Selected = true }; itemsListSearch.Add(selectListItemAll); if (lstSubeject != null) { for (int i = 0; i < lstSubeject.Count; i++) { SelectListItem obj = new SelectListItem(); obj.Selected = false; obj.Value = lstSubeject[i].Id.ToString(); obj.Text = lstSubeject[i].Name; itemsListSearch.Add(obj); itemsListEdit.Add(obj); } } ViewBag.ListSearch = itemsListSearch; ViewBag.EditSearch = itemsListEdit; ViewBag.Grade = new SysAdminAction <Ex_CategoryValue>().List("a.CatCode='KHOI'", "a.Orders desc", 0, 100); ViewBag.Level = new SysAdminAction <Ex_CategoryValue>().List("a.CatCode='DK'", "a.Orders desc", 0, 100); #endregion return(View()); }
public ActionResult Index(int?cauhoi) { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); ViewBag.UsedStateAdd = Ultity.TFunction.GetUsedStateSelected(Ultity.Constant.Active); //ViewBag.UsedState = Ultity.TFunction.GetAllUsedStateSelected(Ultity.Constant.All); ViewBag.Grade = new SysAdminAction <Ex_CategoryValue>().List("a.CatCode='KHOI'", "", 0, 100); ViewBag.DoKho = new SysAdminAction <Ex_CategoryValue>().List("a.CatCode='DK'", "", 0, 100); var radom = new Random(); var currentDate = DateTime.Now; //ViewBag.MaCauHoi = string.IsNullOrEmpty(cauhoi) ? code : cauhoi; return(View()); }
public ActionResult GetData(string fromDate, string toDate, int userId, bool notAccept) { DateTime dtFrom, dtTo; #region +Validate if (string.IsNullOrEmpty(fromDate) || string.IsNullOrEmpty(toDate)) { return(Json(new { status = THelper.Ajax_Return.ErrSystem })); } try { dtFrom = DateTime.ParseExact(fromDate, "dd/MM/yyyy HH:mm", null); dtTo = DateTime.ParseExact(toDate, "dd/MM/yyyy HH:mm", null); } catch (Exception e) { return(Json(new { status = THelper.Ajax_Return.ErrSystem })); } #endregion #region Handler if (AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) { var lst = new SysAdminAction <Cms_HistoryPayment>().HistoryPayment(dtFrom, dtTo, userId); if (notAccept) { lst = lst.Where(x => x.IsActive == false).ToList(); } return(Json(new { status = THelper.Ajax_Return.Ok, value = lst })); } else { var lst = new SysAdminAction <Cms_HistoryPayment>().HistoryPayment(dtFrom, dtTo, WebSecurity.CurrentUserId); if (notAccept) { lst = lst.Where(x => x.IsActive == false).ToList(); } return(Json(new { status = THelper.Ajax_Return.Ok, value = lst })); } #endregion }
public ActionResult Index() { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); var objRef = new object[5]; string sSort = "a.CreatedDate DESC"; objRef[0] = ""; objRef[1] = sSort; objRef[2] = 0; objRef[3] = 100; objRef[4] = 0; var modelList = _sysGroupAction.List(ref objRef); ViewBag.ListGroup = modelList; return(View()); }
public ActionResult Index() { ViewBag.Host = AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll); ViewBag.Add = AuthorizeUser.IsAction(Ultity.Constant.Add); ViewBag.Edit = AuthorizeUser.IsAction(Ultity.Constant.Edit); ViewBag.Delete = AuthorizeUser.IsAction(Ultity.Constant.Delete); ViewBag.UsedStateAdd = Ultity.TFunction.GetUsedStateSelected(Ultity.Constant.Active); ViewBag.UsedState = Ultity.TFunction.GetAllUsedStateSelected(Ultity.Constant.All); #region Danh sách các lớp học string sWhere = (AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) ? " 1=1 " : " a.CreatedBy =" + WebSecurity.CurrentUserId; var lstClass = new SysAdminAction <Cms_Class>().List(sWhere, "a.CreatedDate desc", 0, 100); var itemsListSearch = new List <SelectListItem>(); var itemsListAdd = new List <SelectListItem>(); var selectListItem1 = new SelectListItem { Text = Ultity.Constant.VideoString, Value = Ultity.Constant.Video.ToString(), Selected = false }; var selectListItemAll = new SelectListItem { Text = "Tất cả", Value = "0", Selected = true }; itemsListSearch.Add(selectListItemAll); foreach (var item in lstClass) { SelectListItem obj = new SelectListItem(); obj.Value = item.Id.ToString(); obj.Text = item.Name; obj.Selected = false; itemsListSearch.Add(obj); itemsListAdd.Add(obj); } ViewBag.ListClass = itemsListSearch; ViewBag.ListClassAdd = itemsListAdd; #endregion return(View()); }
public ActionResult GetDataCategory(string key, int type) { try { string sWhere = (AuthorizeUser.IsHost() || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) ? " 1=1 " : " a.CreatedBy =" + WebSecurity.CurrentUserId; if (!string.IsNullOrEmpty(key)) { key = key.Trim(); ViewBag.Search = key; sWhere += "and ( a.Name like N'%" + key + "%' or dbo.ConvertToNoSigned(a.Name) like dbo.ConvertToNoSigned(N'%" + key + "%')) "; } string sSort = "a.Orders DESC"; if (type == 1) //Category { var modelList = new SysAdminAction <Ex_Category>().List(sWhere, sSort, 0, 100); //Check after deleted last item in page . Redirect page close have value smaller if (Request.IsAjaxRequest()) { return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success, Data = modelList })); } } else//CategoryValue { var modelList = new SysAdminAction <Ex_CategoryValue>().List(sWhere, sSort, 0, 100); //Check after deleted last item in page . Redirect page close have value smaller if (Request.IsAjaxRequest()) { return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success, Data = modelList })); } } } catch (Exception exception) { Ultity.TFunction.WriteToLog(exception); return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); }
public ActionResult Delete(string id) { try { if (!string.IsNullOrEmpty(id)) { if (Request.IsAjaxRequest()) { string sWhere = " Id IN (" + id.Trim() + ") "; string sSet = "UsedState = " + Ultity.Constant.Request_Delete; if (!AuthorizeUser.IsHost()) { new SysAdminAction <SysMenu>().Updates(sSet, sWhere); return(Json(new { status = "success", Message = Ultity.Constant.Change_Delete_Success })); } else { #region Nhieu Id thi se xu ly tunh Id 1. Neu ton tai trong Bang khac thi chi dc Update Status ,Con neu k co thi xoa luon if (id.Contains(",")) { string[] tempId = id.Split(','); foreach (var i in tempId) { var menuLienQuan = new SysGroupMenuAction().List("a.MenuId=" + i, string.Empty, 0, 1); if (menuLienQuan.Count > 0) { return(Json(new { status = "warning", Message = Ultity.Constant.Delete_Success_Err })); } new SysAdminAction <SysMenu>().Deletes(" Id=" + i); } } #endregion Nhieu Id thi se xu ly tunh Id 1. Neu ton tai trong Bang khac thi chi dc Update Status ,Con neu k co thi xoa luon #region Xu ly 1 Id else { var menuLienQuan = new SysGroupMenuAction().List("a.MenuId=" + id, string.Empty, 0, 1); if (menuLienQuan.Count > 0) { return(Json(new { status = "warning", Message = Ultity.Constant.Delete_Success_Err })); } new SysAdminAction <SysMenu>().Deletes(sWhere); } #endregion Xu ly 1 Id return(Json(new { status = "success", Message = Ultity.Constant.Delete_Success })); } //Trigger auto to delete table related } } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } catch (Exception exception) { return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } }
public ActionResult Edit(Ex_Exam sysModel) { try { #region Redirect Request int succcess = 0; if (sysModel.Id > 0) { var objTemporary = new SysAdminAction <Ex_Exam>().GetById(sysModel.Id); if (AuthorizeUser.IsAction(Ultity.Constant.Edit) || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) { sysModel.IdGuid = Guid.NewGuid().ToString(); sysModel.CreatedBy = objTemporary.CreatedBy; sysModel.ModifiedDate = DateTime.Now; sysModel.ModifiedBy = WebSecurity.CurrentUserId; sysModel.CreatedDate = objTemporary.CreatedDate; //sysModel.Name = objTemporary.Name; if (!AuthorizeUser.IsHost()) { sysModel.UsedState = objTemporary.UsedState; } succcess = _sysAction.Update(sysModel); } else { succcess = 1; } } else { if (AuthorizeUser.IsAction(Ultity.Constant.Add) || AuthorizeUser.IsAction(Ultity.Constant.ViewEditAll)) { sysModel.IdGuid = Guid.NewGuid().ToString(); sysModel.CreatedBy = WebSecurity.CurrentUserId; sysModel.ModifiedBy = null; sysModel.UsedState = Ultity.Constant.NotAccept; sysModel.CreatedDate = DateTime.Now; sysModel.ModifiedDate = null; succcess = _sysAction.Insert(sysModel); } else { succcess = 1; } } if (succcess > 0) { return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success })); } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); #endregion Redirect Request } catch (Exception exception) { Ultity.TFunction.WriteToLog(exception); } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); }
public ActionResult Delete(string id) { try { if (!string.IsNullOrEmpty(id)) { if (Request.IsAjaxRequest()) { string sWhere = " Id IN (" + id.Trim() + ") "; string sSet = "UsedState = " + Ultity.Constant.Request_Delete; if (!AuthorizeUser.IsHost()) { new SysAdminAction <SysGroup>().Updates(sSet, sWhere); return(Json(new { status = "success", Message = Ultity.Constant.Change_Delete_Success })); } else { if (id.Contains(",")) { var idList = id.Split(','); int checkErr = 0; foreach (var item in idList) { var modelUser = new SysGroupUserAction().GetByGroupId(CommonHelper.Convert.ConvertToInt32(item)); var modelMenu = new SysGroupMenuAction().GetByGroupId(CommonHelper.Convert.ConvertToInt32(item)); if (modelUser.Count > 0 || modelMenu.Count > 0) { checkErr++; } else { new SysAdminAction <SysGroup>().Deletes("Id =" + item); } } if (checkErr > 0) { return(Json(new { status = "warning", Message = Ultity.Constant.Delete_Success_Err })); } } else { var modelUser = new SysGroupUserAction().GetByGroupId(CommonHelper.Convert.ConvertToInt32(id)); var modelMenu = new SysGroupMenuAction().GetByGroupId(CommonHelper.Convert.ConvertToInt32(id)); if (modelUser.Count > 0 || modelMenu.Count > 0) { return(Json(new { status = "warning", Message = Ultity.Constant.Delete_Success_Err })); } else { new SysAdminAction <SysGroup>().Deletes(sWhere); } } return(Json(new { status = "success", Message = Ultity.Constant.Delete_Success })); } //Trigger auto to delete table related } } return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } catch (Exception exception) { return(Json(new { status = "fail", Message = Ultity.Constant.Ajax_Fail })); } }
public ActionResult GetData(string fromDate, string toDate, int userId, bool chkKhoaHoc, bool chkDeThi, string ddlClass, string ddlExam) { DateTime dtFrom, dtTo; var lstResult = new List <ReportClassModel>(); #region +Validate if (string.IsNullOrEmpty(fromDate) || string.IsNullOrEmpty(toDate)) { return(Json(new { status = THelper.Ajax_Return.ErrSystem })); } try { dtFrom = DateTime.ParseExact(fromDate, "dd/MM/yyyy HH:mm", null); dtTo = DateTime.ParseExact(toDate, "dd/MM/yyyy HH:mm", null); } catch (Exception e) { return(Json(new { status = THelper.Ajax_Return.ErrSystem })); } #endregion #region +Handler if (chkKhoaHoc) { string sWhere = "1=1 and a.CreatedDate>='" + dtFrom.ToString("MM/dd/yyy HH:mm") + "' and a.CreatedDate <='" + dtTo.ToString("MM/dd/yyy HH:mm") + "'"; sWhere = (userId == 0 && AuthorizeUser.IsHost()) ? sWhere: (sWhere + "and a.CreatedBy=" + (userId == 0 ? WebSecurity.CurrentUserId : userId) + ""); sWhere = (ddlClass == "0") ? sWhere : (sWhere + "and a.IdGuid='" + ddlClass + "'"); string sql = "Select a.*,(select count(*) from Cms_ClassStudent where ClassGuid=a.IdGuid)as TongHS from Cms_Class a "; sql += " where " + sWhere; var lst = SqlHelper.ExecuteList <Cms_Class>(SqlConnection, CommandType.Text, sql); lst.ForEach(x => { lstResult.Add(new ReportClassModel { Time = Convert.ToDateTime(x.CreatedDate), Loai = "Khóa học", Ten = x.Name, SoLuong = x.TongHS }); }); } if (chkDeThi) { string sWhere = "1=1 and a.CreatedDate>='" + dtFrom.ToString("MM/dd/yyy HH:mm") + "' and a.CreatedDate <='" + dtTo.ToString("MM/dd/yyy HH:mm") + "'"; sWhere = (userId == 0 && AuthorizeUser.IsHost()) ? sWhere : (sWhere + "and a.CreatedBy=" + (userId == 0?WebSecurity.CurrentUserId:userId) + ""); sWhere = (ddlExam == "0") ? sWhere : (sWhere + "and a.IdGuid='" + ddlExam + "'"); var lst = new SysAdminAction <Ex_Exam>().List(sWhere, "a.CreatedDate desc", 0, 100); lst.ForEach(x => { lstResult.Add(new ReportClassModel { Time = Convert.ToDateTime(x.CreatedDate), Loai = "Đề thi", Ten = x.Name, SoLuong = x.TotalStudent }); }); } #endregion return(Json(new { status = THelper.Ajax_Return.Ok, value = lstResult })); }
public ActionResult Payment(int userId, int type, int money) { string sWhere = "1=1"; var modelUser = new SysUserAction().GetById(userId); if (AuthorizeUser.IsHost()) { if (type == 1) { new SysAdminAction <SysUser>().Updates("BCoin=BCoin+" + money, "UserId=" + userId); #region +Thêm vào lịch sử giao dịch new SysAdminAction <Cms_HistoryPayment>().Payment(new Cms_HistoryPayment { IdGuid = Guid.NewGuid().ToString(), FromUser = Ultity.Constant.userIdAdmin, Code = string.Empty, ToUser = userId, BCoin = money, Summary = Ultity.Constant.NapTien, CreatedDate = DateTime.Now, IsShow = true, IsActive = true, }); #endregion } else { if (modelUser.BCoin < money) { return(Json(new { status = "money", Message = Ultity.Constant.Ajax_Fail })); } new SysAdminAction <SysUser>().Updates("BCoin=BCoin-" + money, "UserId=" + userId); #region +Thêm vào lịch sử giao dịch new SysAdminAction <Cms_HistoryPayment>().Payment(new Cms_HistoryPayment { IdGuid = Guid.NewGuid().ToString(), FromUser = Ultity.Constant.userIdAdmin, Code = string.Empty, ToUser = userId, BCoin = money, Summary = Ultity.Constant.AdminRutTien, CreatedDate = DateTime.Now, IsShow = true, IsActive = true, }); #endregion } #region Gửi mail thông báo giao dịch thành công var model = new SysUserAction().GetById(userId); if (type == 1) { Models.THelper.SendMail(model.Email, model.FullName, String.Format("{0:0,0}", money), "Nạp tiền"); } else { Models.THelper.SendMail(model.Email, model.FullName, String.Format("{0:0,0}", money), "Rút tiền"); } #endregion } else { if (WebSecurity.CurrentUserId > 0 && type == -1) { if (modelUser.BCoin < money) { return(Json(new { status = "money", Message = Ultity.Constant.Ajax_Fail })); } #region +Thêm vào lịch sử giao dịch var modelHis = new Cms_HistoryPayment { IdGuid = Guid.NewGuid().ToString(), FromUser = WebSecurity.CurrentUserId, Code = string.Empty, ToUser = WebSecurity.CurrentUserId, BCoin = money, Summary = Ultity.Constant.DeXuatRutTien, CreatedDate = DateTime.Now, IsShow = false, IsActive = false, }; new SysAdminAction <Cms_HistoryPayment>().Payment(modelHis); #endregion #region Gửi thông báo cho Giáo viên và Admin var lstUserInClass = new List <Cms_HistoryPayment>(); lstUserInClass.Add(modelHis); lstUserInClass.ForEach(x => { x.CreatedDateStr = Convert.ToDateTime(x.CreatedDate).ToString("dd/MM/yyy HH:mm"); x.FromUserStr = modelUser.FullName; }); IHubContext contextall = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); NotificationHub hub = new NotificationHub(); //Gửi cho Admin var userAd = new SysAdminAction <SysUser>().GetById((Convert.ToInt32(Ultity.Constant.userIdAdmin))); UserHubModels userAdmin = hub.GetUser(userAd.UserName); if (userAdmin != null) { List <string> connectIds = userAdmin.ConnectionIds.ToList <string>(); connectIds.ForEach(x => { contextall.Clients.Client(x).recieveNotificationFirstTime(lstUserInClass); }); } #endregion } } return(Json(new { status = "success", Message = Ultity.Constant.Ajax_Success })); }