Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ProyectosGridView.RowDataBound      += new GridViewRowEventHandler(ProyectosGridView_RowDataBound);
            ProyectosGridView.PageIndexChanging += new GridViewPageEventHandler(ProyectosGridView_PageIndexChanging);
            ProyectosGridView.Sorting           += new GridViewSortEventHandler(ProyectosGridView_Sorting);

            NuevoButton.Click  += new EventHandler(NuevoButton_Click);
            VolverButton.Click += new EventHandler(VolverButton_Click);

            if (!IsPostBack)
            {
                Session["FiltroActivo"]        = Session["FiltroActivo"] ?? "1";
                Session["FiltroCliente"]       = Session["FiltroCliente"] ?? "-1";
                Session["FiltroProjectLeader"] = Session["FiltroProjectLeader"] ?? "-1";
                ViewState["SortDirection"]     = SortDirection.Ascending;
                ViewState["SortExpression"]    = "Nombre";

                Master.FindControl("FiltrosPanel").Visible = true;

                ProjectLeaderDropDown.DataSource = (from r in DbsrContext.Recurso
                                                    where r.IdTipoRecurso == 1
                                                    orderby r.Nombre
                                                    select r).ToList <Recurso>();
                ProjectLeaderDropDown.DataBind();
                ProjectLeaderDropDown.SelectedValue = Session["FiltroProjectLeader"].ToString();

                ClienteDropDown.DataSource = (from c in DbsrContext.Cliente
                                              orderby c.Nombre
                                              select c).ToList <Cliente>();
                ClienteDropDown.DataBind();
                ClienteDropDown.SelectedValue = Session["FiltroCliente"].ToString();

                BindGrid();
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CancelarButton.Click += new EventHandler(CancelarButton_Click);
            GrabarButton.Click   += new EventHandler(GrabarButton_Click);
            EliminarButton.Click += new EventHandler(EliminarButton_Click);

            if (!IsPostBack)
            {
                ClienteDropDown.DataSource = from c in DbsrContext.Cliente
                                             orderby c.Nombre
                                             select c;
                ClienteDropDown.DataBind();

                CuentaFacturacionDropDown.DataSource = from cf in DbsrContext.CuentaFacturacion
                                                       orderby cf.Nombre
                                                       select cf;
                CuentaFacturacionDropDown.DataBind();

                ModalidadDropDown.DataSource = from m in DbsrContext.ModalidadProyecto
                                               orderby m.IdModalidadProyecto
                                               select m;
                ModalidadDropDown.DataBind();

                ProjectLeaderDropDown.DataSource = from r in DbsrContext.Recurso
                                                   where r.IdTipoRecurso == 1
                                                   select r;
                ProjectLeaderDropDown.DataBind();

                if (Request["Id"] != null)
                {
                    int idProyecto = Convert.ToInt32(Request["Id"]);
                    ViewState["Id"] = idProyecto;

                    var proyecto = DbsrContext.Proyecto.Single(p => p.IdProyecto == idProyecto);

                    NombreTextBox.Text                      = proyecto.Nombre;
                    ClienteDropDown.SelectedValue           = proyecto.IdCliente.ToString();
                    CuentaFacturacionDropDown.SelectedValue = proyecto.IdCuentaFacturacion.ToString();
                    ModalidadDropDown.SelectedValue         = proyecto.IdModalidadProyecto.ToString();
                    ProjectLeaderDropDown.SelectedValue     = proyecto.IdRecursoPL.ToString();
                    if (proyecto.FechaFinEstimada != null)
                    {
                        FechaFinEstimadaTextBox.Text = proyecto.FechaFinEstimada.Value.ToString("dd/MM/yyyy");
                    }
                    if (proyecto.FechaFinReal != null)
                    {
                        FechaFinRealTextBox.Text = proyecto.FechaFinReal.Value.ToString("dd/MM/yyyy");
                    }
                    if (proyecto.FechaInicioEstimada != null)
                    {
                        FechaInicioEstimadaTextBox.Text = proyecto.FechaInicioEstimada.Value.ToString("dd/MM/yyyy");
                    }
                    if (proyecto.FechaInicioReal != null)
                    {
                        FechaInicioRealTextBox.Text = proyecto.FechaInicioReal.Value.ToString("dd/MM/yyyy");
                    }
                    ActivoCheckBox.Checked = proyecto.Activo;
                }
                else
                {
                    ActivoCheckBox.Checked = true;
                }
            }
        }