private void UpdateFunction() { int _groupID = (int)grdvGroup.GetRowCellValue(grdvGroup.FocusedRowHandle, colGroupID); busGroupFunction = new BUS.BUStblGROUP_FUNCTION(); var _oldFunction = busGroupFunction.LayTatCatblGROUP_FUNCTION().Where(a => a.GROUPID == _groupID); var _newFunction = GetGroupFunction(_groupID); foreach (var a in _oldFunction) { busGroupFunction.XoatblGROUP_FUNCTION(a.GROUPID, a.FUNCTIONID, a.MODULEID); } foreach (var b in _newFunction) { busGroupFunction.ThemtblGROUP_FUNCTION(b); } }
private void btnThem_Click(object sender, EventArgs e) { string _GroupName = ""; frmAddGroup frm = new frmAddGroup(); frm.ShowDialog(); if (frm.txtGroupName.Text.Trim() != "") { _GroupName = frm.txtGroupName.Text; busGroupFunction = new BUS.BUStblGROUP_FUNCTION(); var _busGroup = new BUS.BUStblGROUP(); var _dtoGroup = new DTO.DTOtblGROUP(); busFunction = new BUS.BUStblFUNCTION(); _dtoGroup.GROUPNAME = _GroupName; _busGroup.ThemtblGROUP(_dtoGroup); LoadGroup(); int _groupID = _busGroup.LayTatCatblGROUP().OrderBy(a => a.GROUPID).Last().GROUPID; #region Them FUNCTION var lst = (List<DTO.DTOtblFUNCTION>)busFunction.LayTatCatblFUNCTION(); for (int i = 0; i < lst.Count; i++) { var _dtoGroupFunction = new DTO.DTOtblGROUP_FUNCTION(); _dtoGroupFunction.GROUPID = _groupID; _dtoGroupFunction.MODULEID = lst[i].MODULEID; _dtoGroupFunction.FUNCTIONID = lst[i].FUNCTIONID; _dtoGroupFunction.VALUE = false; busGroupFunction.ThemtblGROUP_FUNCTION(_dtoGroupFunction); } #endregion #region Them MODULE var lstModule = busModule.LayTatCatblMODULE().ToList(); for (int i = 0; i < lstModule.Count; i++) { var _dtoGroupModule = new DTO.DTOtblGROUPMODULE(); _dtoGroupModule.GROUPID = _groupID; _dtoGroupModule.MODULEID = lstModule[i].MODULEID; _dtoGroupModule.VALUE = false; busGroupModule.ThemtblGROUPMODULE(_dtoGroupModule); } #endregion } }