Ejemplo n.º 1
0
    private void FillWorkTypes()
    {
        IWorkTypeService service = null;

        try
        {
            // Create service.
            service            = AppService.Create <IWorkTypeService>();
            service.AppManager = this.AppManager;
            // Call service method.
            List <WorkType> workTypes = service.RetrieveAll();

            // Filter active entities.
            IEnumerable <WorkType> activeList = from item in workTypes
                                                where item.IsActive == true && item.ActivityTypeId == 1
                                                orderby item.Name
                                                select item;

            // Bind.
            Session.Add("ActivityEntry_Worktype", workTypes);
            this.ddlWorkTypeList.Items.Clear();
            this.ddlWorkTypeList.DataTextField  = "Name";
            this.ddlWorkTypeList.DataValueField = "Id";
            this.ddlWorkTypeList.DataSource     = activeList;
            this.ddlWorkTypeList.DataBind();

            // Add default item.
            this.ddlWorkTypeList.Items.Insert(0, new ListItem("-- Select --", "0"));

            // Select first item as default.
            if (this.ddlWorkTypeList.Items.Count > 0)
            {
                this.ddlWorkTypeList.SelectedIndex = 0;
            }
            if (this.ddlWorkTypeList.Items.Count == 2)
            {
                this.ddlWorkTypeList.SelectedIndex = 1;
                SetDefaultmins();
            }
        }
        catch { throw; }
        finally
        {
            if (service != null)
            {
                service.Dispose();
            }
        }
    }