private void btnSave_Click(object sender, EventArgs e) { if (treePermission.Nodes.Count == 0) { return; } int userGroupID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (userGroupID == 0) { return; } for (int i = 0; i < treePermission.Nodes.Count; i++) { int perID = TextUtils.ToInt(treePermission.GetNodeByVisibleIndex(i).GetValue(colIDPer)); DataTable dt = TextUtils.Select("Select * from UserGroupRightDistribution WITH(NOLOCK) where FormAndFunctionID = " + perID + " and UserGroupID = " + userGroupID); if (dt.Rows.Count > 0) { if (!treePermission.GetNodeByVisibleIndex(i).Checked) { UserGroupRightDistributionBO.Instance.Delete(TextUtils.ToInt(dt.Rows[0]["ID"])); } } else { if (treePermission.GetNodeByVisibleIndex(i).Checked) { UserGroupRightDistributionModel model = new UserGroupRightDistributionModel(); model.FormAndFunctionID = TextUtils.ToInt(treePermission.GetNodeByVisibleIndex(i).GetValue(colIDPer)); model.UserGroupID = userGroupID; UserGroupRightDistributionBO.Instance.Insert(model); } } } MessageBox.Show("Phân quyền thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }
protected UserGroupRightDistributionFacade(UserGroupRightDistributionModel model) : base(model) { }