public void ActionSave(ModHeThongThongTinModel model) { if (ValidSave(model)) { SaveRedirect(); } }
public void ActionApply(ModHeThongThongTinModel model) { if (ValidSave(model)) { ApplyRedirect(model.RecordID, entity.ID); } }
public void ActionSaveNew(ModHeThongThongTinModel model) { if (ValidSave(model)) { SaveNewRedirect(model.RecordID, entity.ID); } }
public void ActionExport(ModHeThongThongTinModel model) { //lấy danh sách // sap xep tu dong string orderBy = AutoSort(model.Sort); // tao danh sach var dbQuery = ModHeThongThongTinService.Instance.CreateQuery() .Where(!string.IsNullOrEmpty(model.SearchText), o => o.Name.Contains(model.SearchText)) .Where(model.State > 0, o => (o.State & model.State) == model.State) .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("CapDo", model.MenuID, model.LangID)) .OrderBy(orderBy); var listEntity = dbQuery.ToList(); if (listEntity == null) { CPViewPage.SetMessage("Không có dữ liệu."); return; } //khai báo tập hợp bản ghi excel List <List <object> > list = new List <List <object> >(); //khai báo 1 dòng excel List <object> _list = null; WebMenuEntity menu = null; for (int i = 0; listEntity != null && listEntity.Count > 0 && i < listEntity.Count; i++) { _list = new List <object>(); menu = WebMenuService.Instance.CreateQuery() .Where(o => o.Activity == true && o.ID == listEntity[i].MenuID) .ToSingle(); _list.Add(menu?.Name); _list.Add(listEntity[i].Name); list.Add(_list); } //ghi exel string temp_file = CPViewPage.Server.MapPath("~/Data/upload/files/Excel/HTTT_" + string.Format("{0:yyyy_MM_dd}", DateTime.Now) + ".xlsx"); string filePath = CPViewPage.Server.MapPath("~/TTPortal/Templates/Export_HTTT.xlsx"); Excel.Export(list, 1, filePath, temp_file); //CPViewPage.Response.Write("Here!6"); CPViewPage.Response.Clear(); CPViewPage.Response.ContentType = "application/excel"; CPViewPage.Response.AppendHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(temp_file)); CPViewPage.Response.WriteFile(temp_file); CPViewPage.Response.End(); //CPViewPage.Response.Write("Here!"); }
private bool ValidSave(ModHeThongThongTinModel model) { TryUpdateModel(entity); //chong hack entity.ID = model.RecordID; ViewBag.Data = entity; ViewBag.Model = model; CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error; //kiem tra quyen han if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit)) { CPViewPage.Message.ListMessage.Add("Quyền hạn chế."); } //kiem tra ten if (entity.Name.Trim() == string.Empty) { CPViewPage.Message.ListMessage.Add("Nhập tên."); } //kiem tra chuyen muc if (entity.MenuID < 1) { CPViewPage.Message.ListMessage.Add("Chọn chuyên mục."); } if (CPViewPage.Message.ListMessage.Count == 0) { //neu khong nhap code -> tu sinh if (entity.Code.Trim() == string.Empty) { entity.Code = Data.GetCode(entity.Name); } //cap nhat state entity.State = GetState(model.ArrState); //save ModHeThongThongTinService.Instance.Save(entity); return(true); } return(false); }
public void ActionIndex(ModHeThongThongTinModel model) { // sap xep tu dong string orderBy = AutoSort(model.Sort); // tao danh sach var dbQuery = ModHeThongThongTinService.Instance.CreateQuery() .Where(!string.IsNullOrEmpty(model.SearchText), o => o.Name.Contains(model.SearchText)) .Where(model.State > 0, o => (o.State & model.State) == model.State) .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("HeThongThongTin", model.MenuID, model.LangID)) .Take(model.PageSize) .OrderBy(orderBy) .Skip(model.PageIndex * model.PageSize); ViewBag.Data = dbQuery.ToList(); model.TotalRecord = dbQuery.TotalRecord; ViewBag.Model = model; }
public void ActionIndex(ModHeThongThongTinModel model) { // sap xep tu dong string orderBy = AutoSort(model.Sort); var lstDonDk = ModDonDangKyUCSCService.Instance.CreateQuery() .Where(o => o.UserID == model.ThanhVienID && o.Activity == true) .ToSingle(); var lstHSThanhVien = ModHSThanhVienUCSCService.Instance.CreateQuery() .Where(o => o.UserID == model.ThanhVienID && o.Activity == true) .ToSingle(); int donDk = 0, dmId = 0; if (lstDonDk != null) { donDk = lstDonDk.ID; } if (lstHSThanhVien != null) { var dm = ModDauMoiUCSCService.Instance.CreateQuery() .Where(o => o.HSThanhVienUCSCID == lstHSThanhVien.ID) .ToSingle(); if (dm != null) { dmId = dm.ID; } } // tao danh sach var dbQuery = ModHeThongThongTinService.Instance.CreateQuery() .Where(!string.IsNullOrEmpty(model.SearchText), o => o.Name.Contains(model.SearchText)) .Where(model.State > 0, o => (o.State & model.State) == model.State) .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("CapDo", model.MenuID, model.LangID)) .Where(donDk > 0, o => o.DonDangKyUCSCID == donDk) .Where(dmId > 0, o => o.DauMoiUCSCID == dmId) .Take(model.PageSize) .OrderBy(orderBy) .Skip(model.PageIndex * model.PageSize); ViewBag.Data = dbQuery.ToList(); model.TotalRecord = dbQuery.TotalRecord; ViewBag.Model = model; }
public void ActionAdd(ModHeThongThongTinModel model) { if (model.RecordID > 0) { entity = ModHeThongThongTinService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update } else { entity = new ModHeThongThongTinEntity(); // khoi tao gia tri mac dinh khi insert entity.MenuID = model.MenuID; entity.Activity = CPViewPage.UserPermissions.Approve; entity.Order = GetMaxOrder(model); } ViewBag.Data = entity; ViewBag.Model = model; }
private int GetMaxOrder(ModHeThongThongTinModel model) { return(ModHeThongThongTinService.Instance.CreateQuery() .Max(o => o.Order) .ToValue().ToInt(0) + 1); }