public EditReportsRightForm(spAllowedReportsRolesMenu right, string Conn)
        {
            InitializeComponent();
            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            rep = new Repository(connection);
            db  = new SBPayrollDBEntities(connection);

            if (right == null)
            {
                throw new ArgumentNullException("right");
            }
            _right = right;
        }
Esempio n. 2
0
 private void btnEdit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (dataGridViewRights.SelectedRows.Count != 0)
     {
         try
         {
             spAllowedReportsRolesMenu _right = (spAllowedReportsRolesMenu)bindingSourceRights.Current;
             EditReportsRightForm      eus    = new EditReportsRightForm(_right, connection)
             {
                 Owner = this
             };
             eus.Text = "Edit Right";
             eus.ShowDialog();
         }
         catch (Exception ex)
         {
             Utils.ShowError(ex);
         }
     }
 }
Esempio n. 3
0
 private void btnDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (dataGridViewRights.SelectedRows.Count != 0)
     {
         try
         {
             spAllowedReportsRolesMenu _right = (spAllowedReportsRolesMenu)bindingSourceRights.Current;
             if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete Right", "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
             {
                 db.spAllowedReportsRolesMenus.DeleteObject(_right);
                 db.SaveChanges();
                 RefreshGrid();
             }
         }
         catch (Exception ex)
         {
             Utils.ShowError(ex);
         }
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsRightValid())
            {
                try
                {
                    spAllowedReportsRolesMenu _right = new spAllowedReportsRolesMenu();
                    if (cboRoles.SelectedIndex != -1)
                    {
                        _right.RoleId = int.Parse(cboRoles.SelectedValue.ToString());
                    }
                    if (cboMenuItem.SelectedIndex != -1)
                    {
                        _right.MenuItemId = int.Parse(cboMenuItem.SelectedValue.ToString());
                    }
                    _right.Allowed = chkAllowed.Checked;


                    if (db.spAllowedReportsRolesMenus.Any(i => i.RoleId == _right.RoleId && i.MenuItemId == _right.MenuItemId))
                    {
                        MessageBox.Show("Right Exist!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    if (!db.spAllowedReportsRolesMenus.Any(i => i.RoleId == _right.RoleId && i.MenuItemId == _right.MenuItemId))
                    {
                        db.spAllowedReportsRolesMenus.AddObject(_right);
                        db.SaveChanges();

                        ReportsRightsListForm f = (ReportsRightsListForm)this.Owner;
                        f.RefreshGrid();
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    Utils.ShowError(ex);
                }
            }
        }