Example #1
0
        protected void gvPeriod_RowEditing(object sender, GridViewEditEventArgs e)
        {
            unlockControls();
            Int32 code = Convert.ToInt32(gvPeriod.Rows[e.NewEditIndex].Cells[0].Text);

            Entities.Period oPeriod = PeriodBLL.getInstance().getPeriod(code);
            txtCode.Text              = oPeriod.code.ToString();
            txtDescription.Text       = oPeriod.name;
            cboModality.SelectedValue = oPeriod.oPeriodType.code.ToString();
            txtStartDate.Text         = oPeriod.startDate.ToShortDateString();
            txtFinishDate.Text        = oPeriod.finalDate.ToShortDateString();
            cboState.SelectedValue    = oPeriod.state.ToString();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true);
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                int graduationId = -1;
                int periodNumber = -1;
                int.TryParse(Request.Params["Graduation"], out graduationId);
                int.TryParse(Request.Params["Period"], out periodNumber);

                using (PeriodDao dao = new PeriodDao())
                    Period = dao.FindByPkWithDisciplines(graduationId, periodNumber);
            }
            catch (EntityNotFoundException ex)
            {
                throw new HttpException(404, ex.Message);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ValidForm();

                Entities.Period period = new Entities.Period();
                period.Number     = int.Parse(txtNumber.Text.Trim());
                period.Graduation = Graduation;

                using (PeriodDao dao = new PeriodDao())
                    dao.Insert(period);

                Response.Redirect("../Graduation/profile.aspx?Id=" + Graduation.Id);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Example #4
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            Int32 records = 0;

            if (validateData())
            {
                Entities.Period     oPeriod     = new Entities.Period();
                Entities.PeriodType oPeriodType = new Entities.PeriodType();
                oPeriod.code        = Convert.ToInt32(txtCode.Text);
                oPeriod.name        = txtDescription.Text;
                oPeriod.startDate   = DateTime.Parse(txtStartDate.Text);
                oPeriod.finalDate   = DateTime.Parse(txtFinishDate.Text);
                oPeriod.state       = Convert.ToInt16(cboState.SelectedValue);
                oPeriodType.code    = Convert.ToInt32(cboModality.SelectedValue);
                oPeriod.oPeriodType = oPeriodType;

                if (PeriodBLL.getInstance().exists(oPeriod.code))
                {
                    records = PeriodBLL.getInstance().modify(oPeriod);
                }
                else
                {
                    records = PeriodBLL.getInstance().insert(oPeriod);
                }
                blockControls();
                loadData();

                if (records > 0)
                {
                    lblMessage.Text = "Datos almacenados correactamente";
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true);
            }
        }