/// <summary> /// Lấy danh sách thuộc tính theo Id Group: Not in hoặc In /// CanTV 2012/09/24 Tạo mới /// </summary> /// <param name="objPropertiesGroups">objPropertiesGroups: Thuộc tính Id</param> /// <param name="WhereIn">WhereIn = True nếu lấy danh sách thuộc tính trong nhóm thuộc tính | False: Nếu lấy danh sách thuộc tính KHÔNG THUỘC trong nhóm thuộc tính</param> /// <returns></returns> public List <ModProduct_PropertiesListEntity> GetListPropertiesByGroupsId(ModProduct_PropertiesGroupsEntity objPropertiesGroups, bool WhereIn, ref string sPropertiesGroupsId) { List <ModProduct_PropertiesListEntity> lstPropertiesList = null; if (objPropertiesGroups.ID > 0) { if (WhereIn) { lstPropertiesList = ModProduct_PropertiesListService.Instance.CreateQuery() .Where(o => o.PropertiesGroupsId == objPropertiesGroups.ID).ToList(); } else { lstPropertiesList = ModProduct_PropertiesListService.Instance.CreateQuery() .Where(o => o.PropertiesGroupsId == null).ToList(); } } // Lấy tất cả danh sách nếu Id = 0 else if (!WhereIn) { lstPropertiesList = ModProduct_PropertiesListService.Instance .CreateQuery() .Where(o => o.PropertiesGroupsId == null) .ToList(); } if (lstPropertiesList == null) { return(null); } // Lấy danh sách chuỗi foreach (ModProduct_PropertiesListEntity item in lstPropertiesList) { if (string.IsNullOrEmpty(sPropertiesGroupsId)) { sPropertiesGroupsId = item.ID.ToString(); } else { sPropertiesGroupsId = sPropertiesGroupsId + "," + item.ID.ToString(); } } // Nếu trong trường tạo mới, danh sách các Nhóm KH chứa khách hàng sẽ = Null return(lstPropertiesList); }
public void ActionAdd(ModProduct_PropertiesGroupsModel model) { if (model.RecordID > 0) { item = ModProduct_PropertiesGroupsService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update } else { item = new ModProduct_PropertiesGroupsEntity(); // khoi tao gia tri mac dinh khi insert item.Activity = CPViewPage.UserPermissions.Approve; item.CreateDate = DateTime.Now; var objMax = ModProduct_PropertiesGroupsService.Instance.CreateQuery().OrderByDesc(o => o.ID).ToSingle(); if (objMax != null) { item.Order = objMax.Order + 1; item.Code = objMax.Code; } } string sPropertiesInId = string.Empty; string sPropertiesOutId = string.Empty; ViewBag.GetListPropertiesIn = GetListPropertiesByGroupsId(item, true, ref sPropertiesInId); ViewBag.GetListPropertiesOut = GetListPropertiesByGroupsId(item, false, ref sPropertiesOutId); // Khởi tạo danh sách thuộc tính model.PropertiesInId = sPropertiesInId; model.PropertiesOutId = sPropertiesOutId; ViewBag.Data = item; ViewBag.Model = model; }