public void ActionApply(ModProduct_AgentModel model) { if (ValidSave(model)) { ApplyRedirect(model.RecordID, item.ID); } }
public void ActionSaveNew(ModProduct_AgentModel model) { if (ValidSave(model)) { SaveNewRedirect(model.RecordID, item.ID); } }
public void ActionSave(ModProduct_AgentModel model) { if (ValidSave(model)) { SaveRedirect(); } }
public void ActionAdd(ModProduct_AgentModel model) { if (model.RecordID > 0) { item = ModProduct_AgentService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update //// Lấy quốc gia //ModProduct_CityEntity objModProduct_CityEntity = ModProduct_CityService.Instance.GetByID(item.ProductCityId); //// Lấy danh sách tỉnh thành //model.DanhSachTinhThanh = model.ShowTinhThanh(objModProduct_CityEntity.ProductNationalId, objModProduct_CityEntity.ID); //// Lấy danh sách quốc gia //model.DanhSachQuocGia = model.ShowQuocGia(objModProduct_CityEntity.ProductNationalId); } else { item = new ModProduct_AgentEntity(); // khoi tao gia tri mac dinh khi insert item.Activity = CPViewPage.UserPermissions.Approve; item.CreateDate = DateTime.Now; // Lấy danh sách quốc gia: Mặc định là 1 model.DanhSachQuocGia = model.ShowQuocGia(1); // Lấy danh sách tỉnh thành: Mặc định là 1 model.DanhSachTinhThanh = model.ShowTinhThanh(1, 1); } ViewBag.Data = item; ViewBag.Model = model; }
public void ActionIndex(ModProduct_AgentModel model) { // sap xep tu dong string orderBy = AutoSort(model.Sort); // tao danh sach var dbQuery = ModProduct_AgentService.Instance.CreateQuery() .Where(!string.IsNullOrEmpty(model.SearchText), o => o.Name.Contains(model.SearchText)) .Take(model.PageSize) .OrderBy(orderBy) .Skip(model.PageIndex * model.PageSize); ViewBag.Data = dbQuery.ToList(); model.TotalRecord = dbQuery.TotalRecord; ViewBag.Model = model; }
public void ActionRefreshPage(ModProduct_AgentModel model) { TryUpdateModel(item); }
private bool ValidSave(ModProduct_AgentModel model) { TryUpdateModel(item); //chong hack item.ID = model.RecordID; ViewBag.Data = item; 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 (item.Name.Trim() == string.Empty) { CPViewPage.Message.ListMessage.Add("Nhập tên."); } if (CPViewPage.Message.ListMessage.Count == 0) { // Kiểm tra mã xem có trùng với mã nào khác đã có không string sMessError = string.Empty; if (ModProduct_AgentService.Instance.DuplicateCode(item.Code, model.RecordID, ref sMessError)) { if (string.IsNullOrEmpty(sMessError)) { CPViewPage.Message.ListMessage.Add(CPViewControl.ShowMessDuplicate("Mã đại lý", item.Code)); } else { CPViewPage.Message.ListMessage.Add("Lỗi phát sinh: " + sMessError); } return(false); } //neu khong nhap code -> tu sinh if (item.Code.Trim() == string.Empty) { item.Code = Data.GetCode(item.Name); } try { //save ModProduct_AgentService.Instance.Save(item); } catch (Exception ex) { Global.Error.Write(ex); CPViewPage.Message.ListMessage.Add(ex.Message); return(false); } return(true); } return(false); }