示例#1
0
        /// <summary>
        /// Obtains data table information from the database.
        /// </summary>
        private void BindGridViewGrantAll()
        {
            //int piId = -1, biostatId = -1;
            //int fundStatusId = -1, exinternal = -1;

            //Int32.TryParse(ddlInvestor.SelectedValue, out piId);
            //Int32.TryParse(ddlBiostat.SelectedValue, out biostatId);
            //Int32.TryParse(ddlFundStatus1.SelectedValue, out fundStatusId);
            //Int32.TryParse(ddlInternal.SelectedValue, out exinternal);

            //DataTable grantTable = mgr.GetGrantAll(piId, biostatId, fundStatusId, exinternal);

            GridViewGrant.DataSource = GetGrantTable();
            GridViewGrant.DataBind();
        }
示例#2
0
        private void BindControl()
        {
            //ddlPubType
            foreach (Enum pubType in Enum.GetValues(typeof(PubTypeEnum)))
            {
                ListItem item = new ListItem(Enum.GetName(typeof(PubTypeEnum), pubType), pubType.ToString());
                ddlPubType.Items.Add(item);
            }

            using (ProjectTrackerContainer context = new ProjectTrackerContainer())
            {
                var dbQuery = ((IObjectContextAdapter)context).ObjectContext.CreateQuery <DateTime>("CurrentDateTime() ");
                HiddenFieldCurrentDate.Value = dbQuery.AsEnumerable().First().ToShortDateString();
                DateTime currentDate = Convert.ToDateTime(HiddenFieldCurrentDate.Value);


                IDictionary <int, string> dropDownSource = new Dictionary <int, string>();

                //ddlProject
                dropDownSource = context.Projects
                                 .OrderByDescending(d => d.Id)
                                 .Select(x => new { x.Id, FullName = x.Id + " " + x.Title })
                                 .ToDictionary(c => c.Id, c => c.FullName);

                BindDropDownList(ddlProject, dropDownSource, string.Empty);

                //GridViewGrant
                var query = context.GrantAffils
                            .Where(d => d.Id < 4)
                            .OrderBy(d => d.Id);

                GridViewGrant.DataSource = query.ToList();
                GridViewGrant.DataBind();

                ////ddlBiostat
                dropDownSource = context.BioStats
                                 .OrderBy(b => b.Id)
                                 .ToDictionary(c => c.Id, c => c.Name);

                //BindDropDownList(ddlBiostat, dropDownSource, String.Empty);

                GridViewBioStat.DataSource = dropDownSource;
                GridViewBioStat.DataBind();

                if (PubType == PubTypeEnum.Abstract.ToString())
                {
                    //ddlConference
                    dropDownSource = context.Conferences
                                     .Where(d => d.EndDate >= currentDate)
                                     .ToDictionary(c => c.Id, c => (c.ConfName + " | " + c.ConfLoc));

                    BindDropDownList(ddlConference, dropDownSource, "Add a new conference");

                    //dropDownSource = context.Publications.OfType<PubAbstract>()
                    //                .Where(p => p.Status == (int)StatusEnum.SubResub)
                    //                .ToDictionary(c => c.Id, c => (c.Id + " " + c.Title));
                }
                else
                {
                    //dropDownSource = context.Publications.OfType<PubManuscript>()
                    //                .Where(p => p.Status == (int)StatusEnum.SubResub)
                    //                .ToDictionary(c => c.Id, c => (c.Id + " " + c.Title));
                }

                BindDropDownList(ddlPublication, dropDownSource, NewPubItem);
            }
        }