Esempio n. 1
0
        public void InsertPermission(permissionDB permiss)
        {
            using (DataAccesDataContext dbContext = new DataAccesDataContext())
            {
                // incrémenter code permission a partir du dernier code

                List <permissionDB> lsperm = GetPermission();
                int code_permission        = lsperm.OrderBy(w => w.code).LastOrDefault().code + 1;


                permission permission = new permission
                {
                    code_permission = code_permission,
                    description     = permiss.description
                };
                dbContext.permission.InsertOnSubmit(permission);
                dbContext.SubmitChanges();
            }
        }
Esempio n. 2
0
        protected void BtnAjoutPermission_Click(object sender, EventArgs e)
        {
            bool validDescription = false;


            if (String.IsNullOrEmpty(txtdescription.Text))
            {
                lblMessage1.Visible = true;
                MsgDesc.Text        = "veuillez remplir  description!";
            }
            else
            {
                lblMessage1.Visible = false;
                AstreeDonnees       a             = new AstreeDonnees();
                List <permissionDB> lstpermission = a.GetPermission();

                if (lstpermission.Where(w => w.description == txtdescription.Text).Count() > 0)
                {
                    lblMessage1.Visible = true;
                    MsgDesc.Text        = "Description existant!";
                }
                else
                {
                    validDescription = true;
                }
            }
            if ((validDescription))
            {
                AstreeDonnees ad      = new AstreeDonnees();
                permissionDB  permiss = new permissionDB();
                ////permiss.code = Convert.ToInt16(txtcode.Text);
                permiss.description = txtdescription.Text;



                ad.InsertPermission(permiss);
                DataBind();
                this.BindGrid();
            }
        }