/// <summary> /// Cập nhật dữ liệu mới /// </summary> /// <param name="iProductAreaId"></param> /// <param name="ArrPropertiesGroupsIn"></param> private void UpdateProductGroups_PropertiesGroups(int iProductAreaId, string ArrPropertiesGroupsIn) { ArrPropertiesGroupsIn = ArrPropertiesGroupsIn.Trim(','); string sQueryDelete = "[ProductAreaId]=" + iProductAreaId; // Xóa dữ liệu cũ ModProduct_Area_PropretyGroupService.Instance.Delete(sQueryDelete); if (string.IsNullOrEmpty(ArrPropertiesGroupsIn)) { return; } string[] lstPropertiesGroupsIn = ArrPropertiesGroupsIn.Split(','); if (lstPropertiesGroupsIn == null || lstPropertiesGroupsIn.Length <= 0) { return; } ModProduct_Area_PropretyGroupEntity objProductGroupsEntity = null; List <ModProduct_Area_PropretyGroupEntity> lstProductGroupsEntity = new List <ModProduct_Area_PropretyGroupEntity>(); foreach (string item in lstPropertiesGroupsIn) { objProductGroupsEntity = new ModProduct_Area_PropretyGroupEntity(); objProductGroupsEntity.ProductAreaId = iProductAreaId; objProductGroupsEntity.PropertiesGroupId = Convert.ToInt32(item); objProductGroupsEntity.CreateDate = DateTime.Now; lstProductGroupsEntity.Add(objProductGroupsEntity); } ModProduct_Area_PropretyGroupService.Instance.Save(lstProductGroupsEntity); }
public void ActionAdd(ModProduct_Area_PropretyGroupModel model) { if (model.RecordID > 0) { item = ModProduct_Area_PropretyGroupService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update } else { item = new ModProduct_Area_PropretyGroupEntity(); // khoi tao gia tri mac dinh khi insert } ViewBag.Data = item; ViewBag.Model = model; }