protected void Page_Load(object sender, EventArgs e)
 {
     CourseManager curso = new CourseManager();
     GridView2.DataSource = curso.getAll();
     GridView2.DataBind();
     var count = curso.getAll().Count;
     this.contador.Text = Convert.ToString(count);
 }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string codigo = e.Values["CourseID"].ToString();

            CourseManager curso = new CourseManager();
            curso.Remove(Convert.ToInt32(codigo));
            this.GridView2.DataSource = curso.getAll();
            this.GridView2.DataBind();
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string codigo = e.Values["CourseID"].ToString();

            CourseManager curso = new CourseManager();

            curso.Remove(Convert.ToInt32(codigo));
            this.GridView2.DataSource = curso.getAll();
            this.GridView2.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CourseManager curso = new CourseManager();

            GridView2.DataSource = curso.getAll();
            GridView2.DataBind();
            var count = curso.getAll().Count;

            this.contador.Text = Convert.ToString(count);
        }
        /// <summary>
        /// Método que devuelve si un objeto es igual a otro.
        /// </summary>
        /// <param name="obj">Objeto a comparar</param>
        /// <returns>True si es igual. False si es null, no es del mismo tipo o algun atributo es diferente.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            CourseManager cur = (CourseManager)obj;

            return((this.CourseID == cur.CourseID) && (this.Credits == cur.Credits) && (this.DepartmentID == cur.DepartmentID) && (this.Title == cur.Title));
        }
示例#6
0
        protected void addPersona(object sender, EventArgs e)
        {
            CourseManager curso = new CourseManager();

             curso.CourseID=Int32.Parse(this.Id_curso.Text);
             curso.Title = this.Nombre_curso.Text;
             curso.Credits = Int32.Parse(this.Creditos_curso.Text);
             curso.DepartmentID= Int32.Parse(this.Departamento_curso.Text);

             int cursoAdd=curso.Add(curso);

             if(cursoAdd!=-1)
             {
                 //TODO-OK
             }
             else
             {
                 //ERROR
             }

             Response.Redirect("Default.aspx", true);
        }
示例#7
0
        protected void addPersona(object sender, EventArgs e)
        {
            CourseManager curso = new CourseManager();

            curso.CourseID     = Int32.Parse(this.Id_curso.Text);
            curso.Title        = this.Nombre_curso.Text;
            curso.Credits      = Int32.Parse(this.Creditos_curso.Text);
            curso.DepartmentID = Int32.Parse(this.Departamento_curso.Text);

            int cursoAdd = curso.Add(curso);

            if (cursoAdd != -1)
            {
                //TODO-OK
            }
            else
            {
                //ERROR
            }

            Response.Redirect("Default.aspx", true);
        }
        /// <summary>
        /// Método que añade un nuevo curso a la base de datos
        /// </summary>
        /// <param name="p">Objeto curso para añadir</param>
        /// <returns>Identificador del curso</returns>
        public int Add(CourseManager p)
        {
            try
            {
                using (cntSchool cnt = new cntSchool())
                {
                    Course curso = new  Course();

                    curso.CourseID     = p.CourseID;
                    curso.Credits      = p.Credits;
                    curso.DepartmentID = p.DepartmentID;
                    curso.Title        = p.Title;

                    cnt.Course.Add(curso);
                    cnt.SaveChanges();

                    return(p.CourseID);
                }
            }
            catch (Exception e)
            {
                return(-1);
            }
        }
示例#9
0
        /// <summary>
        /// Método que añade un nuevo curso a la base de datos
        /// </summary>
        /// <param name="p">Objeto curso para añadir</param>
        /// <returns>Identificador del curso</returns>
        public int Add(CourseManager p)
        {
            try
            {
                using (cntSchool cnt = new cntSchool())
                {
                    Course curso = new  Course();

                    curso.CourseID = p.CourseID;
                    curso.Credits = p.Credits;
                    curso.DepartmentID = p.DepartmentID;
                    curso.Title = p.Title;

                    cnt.Course.Add(curso);
                    cnt.SaveChanges();

                    return p.CourseID;
                }
            }
            catch (Exception e)
            {
                return -1;
            }
        }