Exemplo n.º 1
0
 private void saveBtn_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in drepturiGrid.Rows)
     {
         var drept    = (Drept)row.DataBoundItem;
         var areDrept = row.Cells["check"].Value;
         var rolDrept = RolDrept.GetAll().Where(p => p.IdDrept == drept.ID && p.IdRol == RolObject.ID).FirstOrDefault();
         if (rolDrept == null)
         {
             rolDrept         = new RolDrept();
             rolDrept.IdRol   = RolObject.ID;
             rolDrept.IdDrept = drept.ID;
         }
         if (areDrept == null)
         {
             rolDrept.AreDrept = false;
         }
         else
         {
             rolDrept.AreDrept = (bool)areDrept;
         }
         var result = rolDrept.Save();
         if (row.Index == drepturiGrid.Rows.Count - 1)
         {
             MessageBox.Show(result.Message);
             if (result.Status == StatusEnum.Saved)
             {
                 DialogResult = DialogResult.OK;
             }
         }
     }
 }
Exemplo n.º 2
0
        public void GetAllRolDreptTest()
        {
            var list = RolDrept.GetAll();

            if (list == null)
            {
                Assert.Fail();
            }
        }
Exemplo n.º 3
0
        private void CheckRights()
        {
            var rightsForRole = RolDrept.GetAll().Where(p => p.IdRol == this.RolObject.ID && p.AreDrept == true).Select(p => p.DreptObject).ToList();

            foreach (DataGridViewRow row in drepturiGrid.Rows)
            {
                if (rightsForRole.Contains((Drept)row.DataBoundItem))
                {
                    row.Cells["check"].Value = true;
                }
            }
        }
Exemplo n.º 4
0
 private void LoadData()
 {
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca bancile...";
     Banca.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca delegatii...";
     Delegat.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca drepturile...";
     Drept.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca facturile...";
     FacturaIntrare.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca facturile...";
     FacturaIesire.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca firmele...";
     Firma.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     Plata.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PlataFactura.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PozitieFacturaIesire.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PozitieFacturaIntrare.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca produsele...";
     Produs.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca rolurile...";
     Rol.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     RolDrept.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca stocurile...";
     Stoc.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca utilizatorii...";
     Utilizator.GetAll();
 }
Exemplo n.º 5
0
        private bool HasRight(TreeNode node)
        {
            var rightName = node.Text;
            var rolDrept  = RolDrept.GetAll().Where(p => p.DreptObject.Nume == rightName && p.IdRol == LoggedUser.IdRol).FirstOrDefault();

            if (rolDrept == null)
            {
                node.Collapse();
                MessageBox.Show("Nu aveti acest drept!");
                return(false);
            }
            else
            {
                if (rolDrept.AreDrept == false)
                {
                    node.Collapse();
                    MessageBox.Show("Nu aveti dreptul asupra: " + rolDrept.DreptObject.Nume);
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 6
0
        public List <Drept> GetRights(Utilizator user)
        {
            var rightList = RolDrept.GetAll().Where(p => p.IdRol == user.IdRol).Select(p => p.DreptObject).ToList();

            return(rightList);
        }