コード例 #1
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     Recopie();
     if (current.Control())
     {
         if (!current.Update)
         {
             NiveauAcces f = NiveauAccesBLL.Save(current);
             if (f != null ? f.Id > 0 : false)
             {
                 current.Id     = f.Id;
                 current.Update = true;
                 AddRow(f);
                 Messages.Succes();
             }
         }
         else
         {
             if (NiveauAccesBLL.Update(current))
             {
                 UpdateRow(current);
                 Messages.Succes();
             }
         }
         Reset();
     }
 }
コード例 #2
0
 private void dgv_liste_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgv_liste.CurrentRow.Cells["id_"].Value != null)
         {
             Int32 id = Convert.ToInt32(dgv_liste.CurrentRow.Cells["id_"].Value);
             if (id > 0)
             {
                 NiveauAcces f = NiveauAccesBLL.One(id);
                 if (e.ColumnIndex == 3)
                 {
                     if (DialogResult.Yes == Messages.Confirmation(Mots.Supprimer.ToLower()))
                     {
                         if (NiveauAccesBLL.Delete(f))
                         {
                             DeleteRow(f);
                             Reset();
                             Messages.Succes();
                         }
                     }
                 }
                 else
                 {
                     Populate(f);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Messages.Exception(ex);
     }
 }
コード例 #3
0
        private void LoadGrille()
        {
            dgv_liste.Rows.Clear();
            string             query = "select * from niveau_acces where super = false order by id";
            List <NiveauAcces> l     = NiveauAccesBLL.List(query);

            foreach (NiveauAcces n in l)
            {
                AddRow(n);
            }
            Reset();
        }
コード例 #4
0
 private void btn_delete_Click(object sender, EventArgs e)
 {
     if (current != null ? current.Id > 0 : false)
     {
         if (DialogResult.Yes == Messages.Confirmation(Mots.Supprimer.ToLower()))
         {
             if (NiveauAccesBLL.Delete(current))
             {
                 DeleteRow(current);
                 Reset();
                 Messages.Succes();
             }
         }
     }
 }
コード例 #5
0
        private void LoadAllNiveau()
        {
            niveaux.Clear();
            string query = "select * from niveau_acces where super = false order by id";

            niveaux = NiveauAccesBLL.List(query);
            com_niveau.DisplayMember = "Designation";
            com_niveau.ValueMember   = "Id";
            com_niveau.DataSource    = new BindingSource(niveaux, null);

            foreach (NiveauAcces f in niveaux)
            {
                com_niveau.AutoCompleteCustomSource.Add(f.Designation);
            }
            com_niveau.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            com_niveau.AutoCompleteSource = AutoCompleteSource.CustomSource;
        }
コード例 #6
0
        private NiveauAcces SuperNiveau()
        {
            NiveauAcces        n     = new NiveauAcces();
            string             query = "select * from niveau_acces where super = true limit 1";
            List <NiveauAcces> l     = NiveauAccesBLL.List(query);

            if (l != null ? l.Count > 0 : false)
            {
                n = l[0];
            }
            else
            {
                n.Super       = true;
                n.Description = "Super Administrateur";
                n.Designation = "Super Administrateur";
                n             = NiveauAccesBLL.Save(n);
            }

            query = "select * from formulaires";
            List <Formulaires> lf = FormulairesBLL.List(query);

            foreach (Formulaires f in lf)
            {
                AutorisationFormulaire a = AutorisationFormulaireBLL.One(AutorisationFormulaireBLL.Current(new AutorisationFormulaire(n, f, true)));
                if (a != null ? a.Id < 1 : true)
                {
                    AutorisationFormulaireBLL.Save(new AutorisationFormulaire(n, f, true));
                }
            }

            query = "select * from ressources";
            List <Ressources> lr = RessourcesBLL.List(query);

            foreach (Ressources r in lr)
            {
                AutorisationRessource a = AutorisationRessourceBLL.One(AutorisationRessourceBLL.Current(new AutorisationRessource(n, r, true)));
                if (a != null ? a.Id < 1 : true)
                {
                    AutorisationRessourceBLL.Save(new AutorisationRessource(n, r, true));
                }
            }
            return(n);
        }
コード例 #7
0
        private void txt_search_TextChanged(object sender, EventArgs e)
        {
            string search = txt_search.Text.Trim();

            if (search.Length > 0)
            {
                dgv_liste.Rows.Clear();
                string             query = "select * from niveau_acces where designation like '" + search + "%' or description like '" + search + "%'";
                List <NiveauAcces> l     = NiveauAccesBLL.List(query);
                foreach (NiveauAcces f in l)
                {
                    AddRow(f);
                }
                Reset();
            }
            else
            {
                LoadGrille();
            }
        }
コード例 #8
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            NiveauAcces f = new NiveauAcces();

            f.Designation = txt_designation.Text.Trim();
            f.Description = txt_description.Text.Replace("'", "''");
            if (f.Control())
            {
                f = NiveauAccesBLL.Save(f);
                if (f != null ? f.Id > 0 : false)
                {
                    current.niveaux.Add(f);
                    current.com_niveau.Refresh();
                    current.com_niveau.DataSource = new BindingSource(current.niveaux, null);
                    current.com_niveau.ResetText();
                    current.com_niveau.SelectedText = f.Designation;
                    current.current = f;
                    this.Close();
                }
            }
        }
コード例 #9
0
 private void dgv_liste_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         if (dgv_liste.Rows.Count > 0)
         {
             if (dgv_liste.CurrentRow.Cells["id_"].Value != null)
             {
                 Int32 id = (Int32)dgv_liste.CurrentRow.Cells["id_"].Value;
                 if (id > 0)
                 {
                     NiveauAcces f = NiveauAccesBLL.One(id);
                     Populate(f);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Messages.Exception(ex);
     }
 }