예제 #1
0
        public List<DCControl> Create(Guid reportID)
        {
            ReportDatabaseEntities db = new ReportDatabaseEntities();
            var result = new List<DCControl>();
            var data = (from ctrl in db.WebReportParameters.ToList().OrderBy(k => k.OrderByControl).ToList()
                        join CP in db.WebReportParamCascadeMappings.ToList() on ctrl.RPId_PK equals CP.PRId_FK
                        where CP.ReportId_FK==reportID
                        && ctrl.isActive== true
                        orderby CP.OrderByControl
                        select new { Control = ctrl, CParam = CP});
            foreach(var d in data)
            {
                DCControl ddl;
                switch (d.Control.Name )
                {
                    case "Customer":
                    ddl = new CustomerDropDown();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.Customers
                                               select new OptionValue
                                               {
                                                   DisplayUniqueID = c.CustomerId_PK,
                                                   DisplayValue = c.FirstName + " " + c.LastName,
                                                   ParentID =  (Guid) c.CountryID_FK

                                               }
                               ).ToList<OptionValue>();
                    ddl.SelectedValue  = ddl.ControlType.Options[0];
                    ddl.ngModel = ddl.SelectedValue.ToString();
                    break;
                    case "Country":
                    ddl = new CountryDropDown();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.Countries
                                               select new OptionValue
                                               {
                                                   DisplayUniqueID = c.CountryId_PK,
                                                   DisplayValue = c.Name

                                               }
                            ).ToList<OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel = ddl.SelectedValue.ToString();
                    break;
                    case "State":
                    ddl = new CountryDropDown();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.States

                                             select new OptionValue
                                               {
                                                   DisplayUniqueID = c.StateId_PK,
                                                   DisplayValue = c.Name,
                                                   ParentID = (Guid) c.CountryID_FK
                                               }
                            ).ToList<OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel = ddl.SelectedValue.ToString();
                    break;
                    case "City":
                        ddl = new CountryDropDown();
                        ddl.Name = d.Control.Name;
                        ddl.Title = d.Control.Name;
                        ddl.ControlType.Options = (from c in db.Cities

                                                   select new OptionValue
                                                   {
                                                       DisplayUniqueID = c.CityId_PK,
                                                       DisplayValue = c.Name,
                                                       ParentID = (Guid)c.StateID_FK
                                                   }
                                ).ToList<OptionValue>();
                        ddl.SelectedValue = ddl.ControlType.Options[0];
                        ddl.ngModel = ddl.SelectedValue.ToString();
                        break;
                    case "Languages":
                    ddl = new LanguageCheckBox();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from r in
                                                   ((from c in db.Languages
                                                     select new LanguageList
                                                     {
                                                         LanguageId = c.LanguageId_PK,
                                                         Name = c.Name,

                                                     }).ToList())
                                               select new OptionValue
                                               {
                                                   DisplayUniqueID = r.LanguageId,
                                                   DisplayValue = r.Name
                                               }
                            ).ToList<OptionValue>();
                    break;
                    case "DateOfJoining":
                    ddl = new DateTimeBox();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    break;
                    case "DateOfBirth":
                    ddl = new DateTimeBox();
                    ddl.Name = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    break;
                    default:
                        ddl = null;
                        break;
                }
                if (ddl != null)
                {
                    result.Add(ddl);
                }

            }
            return result;
        }
예제 #2
0
        public List <DCControl> Create(Guid reportID)
        {
            ReportDatabaseEntities db = new ReportDatabaseEntities();
            var result = new List <DCControl>();
            var data   = (from ctrl in db.WebReportParameters.ToList().OrderBy(k => k.OrderByControl).ToList()
                          join CP in db.WebReportParamCascadeMappings.ToList() on ctrl.RPId_PK equals CP.PRId_FK
                          where CP.ReportId_FK == reportID &&
                          ctrl.isActive == true
                          orderby CP.OrderByControl
                          select new { Control = ctrl, CParam = CP });

            foreach (var d in data)
            {
                DCControl ddl;
                switch (d.Control.Name)
                {
                case "Customer":
                    ddl       = new CustomerDropDown();
                    ddl.Name  = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.Customers
                                               select new OptionValue
                    {
                        DisplayUniqueID = c.CustomerId_PK,
                        DisplayValue = c.FirstName + " " + c.LastName,
                        ParentID = (Guid)c.CountryID_FK
                    }
                                               ).ToList <OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel       = ddl.SelectedValue.ToString();
                    break;

                case "Country":
                    ddl       = new CountryDropDown();
                    ddl.Name  = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.Countries
                                               select new OptionValue
                    {
                        DisplayUniqueID = c.CountryId_PK,
                        DisplayValue = c.Name
                    }
                                               ).ToList <OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel       = ddl.SelectedValue.ToString();
                    break;

                case "State":
                    ddl       = new CountryDropDown();
                    ddl.Name  = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.States

                                               select new OptionValue
                    {
                        DisplayUniqueID = c.StateId_PK,
                        DisplayValue = c.Name,
                        ParentID = (Guid)c.CountryID_FK
                    }
                                               ).ToList <OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel       = ddl.SelectedValue.ToString();
                    break;

                case "City":
                    ddl       = new CountryDropDown();
                    ddl.Name  = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from c in db.Cities

                                               select new OptionValue
                    {
                        DisplayUniqueID = c.CityId_PK,
                        DisplayValue = c.Name,
                        ParentID = (Guid)c.StateID_FK
                    }
                                               ).ToList <OptionValue>();
                    ddl.SelectedValue = ddl.ControlType.Options[0];
                    ddl.ngModel       = ddl.SelectedValue.ToString();
                    break;

                case "Languages":
                    ddl       = new LanguageCheckBox();
                    ddl.Name  = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    ddl.ControlType.Options = (from r in
                                               ((from c in db.Languages
                                                 select new LanguageList
                    {
                        LanguageId = c.LanguageId_PK,
                        Name = c.Name,
                    }).ToList())
                                               select new OptionValue
                    {
                        DisplayUniqueID = r.LanguageId,
                        DisplayValue = r.Name
                    }
                                               ).ToList <OptionValue>();
                    break;

                case "DateOfJoining":
                    ddl       = new DateTimeBox();
                    ddl.Name  = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    break;

                case "DateOfBirth":
                    ddl       = new DateTimeBox();
                    ddl.Name  = d.Control.Name;
                    ddl.Title = d.Control.Name;
                    break;

                default:
                    ddl = null;
                    break;
                }
                if (ddl != null)
                {
                    result.Add(ddl);
                }
            }
            return(result);
        }