Ejemplo n.º 1
0
        protected void guardar()
        {
            Boolean camposValidos = true;

            if (!Util.Validate.Text(txtNombre.Text.Trim()))
            {
                ErrorManager.SetError(txtNombre, "El nombre no debe estar vacio y debe contener solo letras");
                camposValidos = false;
            }
            else
            {
                ErrorManager.SetError(txtNombre, "");
            }
            if (!Util.Validate.Legajo(txtDescripcion.Text))
            {
                ErrorManager.SetError(txtDescripcion, "La descripcion no puede estar vacia");
                camposValidos = false;
            }
            else
            {
                ErrorManager.SetError(txtDescripcion, "");
            }
            if (!Util.Validate.Horas(txtHsSemanales.Text, txtHsTotales.Text))
            {
                ErrorManager.SetError(txtHsTotales, "Las horas totales deben ser mayor que las horas semanales");
                camposValidos = false;
            }
            else
            {
                ErrorManager.SetError(txtDescripcion, "");
            }

            if (!camposValidos)
            {
                return;
            }
            Business.Entities.Materia mat  = new Business.Entities.Materia(txtNombre.Text.Trim(), txtDescripcion.Text, int.Parse(txtHsSemanales.Text), int.Parse(txtHsTotales.Text));
            Business.Entities.Plan    plan = new Business.Entities.Plan();
            plan.IdPlan = (int)cmbPlanes.SelectedValue;
            mat.Plan    = plan;
            if (ismodi)
            {
                mat.IdMateria = materia.IdMateria;
                bool guardado = Business.Logic.ABMmateria.modificarMateria(mat);
                if (guardado)
                {
                    MessageBox.Show(this.Owner, "Guardado con exito", "Exito", MessageBoxButtons.OK);
                    this.saved = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(this.Owner, "No se pudo modificar la materia, es probable que ya exista otra materia con ese nombre ", "Sin Exito", MessageBoxButtons.OK);
                }
            }
            else
            {
                bool guardado = Business.Logic.ABMmateria.altaMateria(mat);
                if (guardado)
                {
                    MessageBox.Show(this.Owner, "Guardado con exito", "Exito", MessageBoxButtons.OK);
                    this.saved = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(this.Owner, "No se pudo guardar materia, es probable que ya exista otra materia con ese nombre", "Sin Exito", MessageBoxButtons.OK);
                }
            }
        }
Ejemplo n.º 2
0
        protected void guardar()
        {
            Boolean camposValidos = true;

            if (!Util.Validate.Text(txtNombre.Text.Trim()))
            {
                ErrorManager.SetError(txtNombre, "El nombre no debe estar vacio y debe contener solo letras");
                camposValidos = false;
            }
            else
            {
                ErrorManager.SetError(txtNombre, "");
            }
            if (!Util.Validate.Cupo(txtCupo.Text))
            {
                ErrorManager.SetError(txtCupo, "El cupo debe ser mayor a 0 y menor a 100");
                camposValidos = false;
            }
            else
            {
                ErrorManager.SetError(txtCupo, "");
            }

            if (!camposValidos)
            {
                return;
            }
            Business.Entities.Curso   cur = new Business.Entities.Curso(txtNombre.Text.Trim(), int.Parse(txtCupo.Text));
            Business.Entities.Materia mat = new Business.Entities.Materia();
            mat.IdMateria = (int)cmbMateria.SelectedValue;
            cur.Materia   = mat;
            Business.Entities.Comision com = new Business.Entities.Comision();
            com.IdComision = (int)cmbComision.SelectedValue;
            cur.Comision   = com;
            if (ismodi)
            {
                cur.IdCurso = curso.IdCurso;
                bool guardado = Business.Logic.ABMcurso.modificarCurso(cur);
                if (guardado)
                {
                    MessageBox.Show(this.Owner, "Modificado con exito", "Exito", MessageBoxButtons.OK);
                    this.saved = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(this.Owner, "No se pudo modificar el curso, es probable que ya exista otro curso con ese mismo nombre", "Sin Exito", MessageBoxButtons.OK);
                }
            }
            else
            {
                bool guardado = Business.Logic.ABMcurso.altaCurso(cur);
                if (guardado)
                {
                    MessageBox.Show(this.Owner, "Guardado con exito", "Exito", MessageBoxButtons.OK);
                    this.saved = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(this.Owner, "No se pudo guardar curso, es probable que ya exista otro curso con ese nombre", "Sin Exito", MessageBoxButtons.OK);
                }
            }
        }