Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (treePermission.Nodes.Count == 0)
            {
                return;
            }
            int userID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (userID == 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 UserRightDistribution WITH(NOLOCK) where FormAndFunctionID = "
                                                + perID + " and UserID = " + userID);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        if (!treePermission.GetNodeByVisibleIndex(i).Checked)
                        {
                            UserRightDistributionBO.Instance.Delete(TextUtils.ToInt(dt.Rows[0][0]));
                        }
                    }
                    else
                    {
                        if (treePermission.GetNodeByVisibleIndex(i).Checked)
                        {
                            UserRightDistributionModel model = new UserRightDistributionModel();
                            model.FormAndFunctionID = TextUtils.ToInt(treePermission.GetNodeByVisibleIndex(i).GetValue(colIDPer));
                            model.UserID            = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                            UserRightDistributionBO.Instance.Insert(model);
                        }
                    }
                }
            }
            MessageBox.Show("Phân quyền thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            List <int> listPermission = new List <int>()
            {
                23, 43, 76
            };
            DataTable dt = TextUtils.Select("select * from vUserInfo where DepartMentId<>1 and id <> 17");

            foreach (DataRow row in dt.Rows)
            {
                int userID = TextUtils.ToInt(row[0]);
                foreach (int item in listPermission)
                {
                    UserRightDistributionModel model = new UserRightDistributionModel();
                    model.UserID            = userID;
                    model.FormAndFunctionID = item;
                    UserRightDistributionBO.Instance.Insert(model);
                }
            }
            MessageBox.Show("OK");
        }
 protected UserRightDistributionFacade(UserRightDistributionModel model) : base(model)
 {
 }