Example #1
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int Id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());

            EntityBiblio.Model.Professor Prof = (from p in dB.Professors where p.Id == Id select p).Single();
            dB.Professors.Remove(Prof);
            dB.SaveChanges();
            Response.Redirect("/Professor.aspx");
        }
        protected void Depart_SelectedIndexChanged(object sender, EventArgs e)
        {
            EntityBiblio.Model.Professor prof = new EntityBiblio.Model.Professor();
            var elmId = dB.Departements.Where(b => b.NomDep == Depart.SelectedValue).FirstOrDefault();

            prof.Nom    = NomProf.Text;
            prof.Prenom = prenomProf.Text;
            prof.Tel    = Tel.Text;
            prof.Email  = Email.Text;
            prof.CIN1   = Cin.Text;
            prof.IdDep  = elmId.Id;
            dB.Professors.Add(prof);
            dB.SaveChanges();
            Response.Redirect("/Professor.aspx");
        }