Exemplo n.º 1
0
    private void FillLists()
    {
        var  rules     = Rules.GetAll(this.company.Id);
        var  rulesList = new StringBuilder("");
        bool firstRule = true;

        this.RulesIds = string.Empty;

        if (this.Auditory.PlannedOn != null)
        {
            rulesList.Append("<label class=\"col-sm-10 control-label\" style=\"text-align:left;\"><strong>");
        }
        else
        {
            rulesList.Append("<select class=\"col-sm-12\" id=\"CmbRules\" multiple=\"multiple\">");
        }

        foreach (var rule in rules.OrderBy(p => p.Description))
        {
            bool selected = this.Auditory.Rules.Any(r => r.Id == rule.Id);
            if (selected)
            {
                this.RulesIds += rule.Id + "|";
            }

            if (this.Auditory.PlannedOn != null)
            {
                if (selected)
                {
                    if (firstRule)
                    {
                        firstRule = false;
                    }
                    else
                    {
                        rulesList.Append(", ");
                    }

                    rulesList.Append(rule.Description);
                }
            }
            else
            {
                rulesList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    rule.Id,
                    rule.Description,
                    selected ? " selected=\"selected\"" : string.Empty);
            }
        }

        if (this.Auditory.PlannedOn != null)
        {
            rulesList.Append("</strong></label>");
        }
        else
        {
            rulesList.Append("</select>");
        }

        this.LtCmbRules.Text = rulesList.ToString();

        var employesList  = new StringBuilder();
        var auditedList   = new StringBuilder();
        var planningList  = new StringBuilder();
        var auditorList   = new StringBuilder();
        var closedList    = new StringBuilder();
        var validatedList = new StringBuilder();

        employesList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        auditedList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        planningList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        auditorList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        closedList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        validatedList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        foreach (var employee in Employee.ByCompany(this.company.Id))
        {
            if (employee.DisabledDate == null || this.Auditory.InternalResponsible.Id == employee.Id)
            {
                employesList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    employee.Id,
                    employee.FullName,
                    this.Auditory.InternalResponsible.Id == employee.Id ? " selected=\"selected\"" : string.Empty);
            }

            if (employee.DisabledDate == null || this.Auditory.PlannedBy.Id == employee.Id)
            {
                planningList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    employee.Id,
                    employee.FullName,
                    this.Auditory.PlannedBy.Id == employee.Id ? " selected=\"selected\"" : string.Empty);
            }

            if (employee.DisabledDate == null || this.Auditory.ValidatedBy.Id == employee.Id)
            {
                validatedList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    employee.Id,
                    employee.FullName,
                    this.Auditory.ValidatedBy.Id == employee.Id ? " selected=\"selected\"" : string.Empty);
            }

            if (employee.DisabledDate == null)
            {
                auditedList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}"">{1}</option>",
                    employee.Id,
                    employee.FullName);
                closedList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}"">{1}</option>",
                    employee.Id,
                    employee.FullName);
                auditorList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}"">{1}</option>",
                    employee.Id,
                    employee.FullName);
            }
        }

        this.LtCmbInternalResponsible.Text = employesList.ToString();
        this.LtClosedByList.Text           = closedList.ToString();
        this.LtValidatedByList.Text        = validatedList.ToString();
        this.LtWhatHappendByList.Text      = validatedList.ToString();

        var addressList = new StringBuilder();

        employesList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        foreach (var address in CompanyAddress.GetAddressByCompanyId(this.company))
        {
            addressList.AppendFormat(
                CultureInfo.InvariantCulture,
                @"<option value=""{0}""{2}>{1}</option>",
                address.Id,
                address.Description,
                this.Auditory.CompanyAddressId == address.Id ? " selected=\"selected\"" : string.Empty);
        }

        this.LtCmbAddress.Text = addressList.ToString();

        var providerList = new StringBuilder();

        providerList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        if (this.Auditory.Type == 1 || this.Auditory.Type == 2)
        {
            foreach (var provider in Provider.ByCompany(this.company.Id))
            {
                if (this.auditoryId > 0 || provider.Active)
                {
                    providerList.AppendFormat(
                        CultureInfo.InvariantCulture,
                        @"<option value=""{0}""{2}>{1}</option>",
                        provider.Id,
                        provider.Description,
                        this.Auditory.Provider.Id == provider.Id ? " selected=\"selected\"" : string.Empty);
                }
            }
        }

        this.LtCmbProvider.Text = providerList.ToString();

        var customerList = new StringBuilder();

        customerList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        if (this.Auditory.Type == 1 || this.Auditory.Type == 2)
        {
            foreach (var customer in Customer.ByCompany(this.company.Id))
            {
                if (this.auditoryId > 0 || customer.Active)
                {
                    customerList.AppendFormat(
                        CultureInfo.InvariantCulture,
                        @"<option value=""{0}""{2}>{1}</option>",
                        customer.Id,
                        customer.Description,
                        this.Auditory.Customer.Id == customer.Id ? " selected=\"selected\"" : string.Empty);
                }
            }
        }

        this.LtCmbCustomer.Text = customerList.ToString();
    }
Exemplo n.º 2
0
    private void FillLists()
    {
        var processes   = Process.ByCompany(this.company.Id);
        var processList = new StringBuilder("<option value=\"-1\">").Append(this.Dictionary["Common_SelectOne"]).Append("</option>");

        foreach (var process in processes.OrderBy(p => p.Description))
        {
            processList.AppendFormat(
                CultureInfo.InvariantCulture,
                @"<option value=""{0}"">{1}</option>",
                process.Id,
                process.Description);
        }

        this.LtProcessList.Text = processList.ToString();


        var  rules     = Rules.GetAll(this.company.Id);
        var  rulesList = new StringBuilder("");
        bool firstRule = true;

        this.RulesIds = string.Empty;

        if (this.Auditory.PlannedOn != null)
        {
            rulesList.Append("<label class=\"col-sm-10 control-label\" style=\"text-align:left;\"><strong>");
        }
        else
        {
            rulesList.Append("<select class=\"col-sm-12\" id=\"CmbRules\" multiple=\"multiple\" onchange=\"CalculeTotalQuestions();\">");
        }

        foreach (var rule in rules.Where(r => r.Active == true).OrderBy(p => p.Description))
        {
            bool selected = this.Auditory.Rules.Any(r => r.Id == rule.Id);
            if (selected)
            {
                this.RulesIds += rule.Id + "|";
            }

            if (this.Auditory.PlannedOn != null)
            {
                if (selected)
                {
                    if (firstRule)
                    {
                        firstRule = false;
                    }
                    else
                    {
                        rulesList.Append(", ");
                    }

                    rulesList.Append(rule.Description);
                }
            }
            else
            {
                rulesList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    rule.Id,
                    rule.Description,
                    selected ? " selected=\"selected\"" : string.Empty);
            }
        }

        if (this.Auditory.PlannedOn != null)
        {
            rulesList.Append("</strong></label>");
        }
        else
        {
            rulesList.Append("</select>");
        }

        this.LtCmbRules.Text = rulesList.ToString();

        var employesList = new StringBuilder();
        var auditedList  = new StringBuilder();
        var planningList = new StringBuilder();
        //var closedList = new StringBuilder();
        var validatedList = new StringBuilder();

        employesList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        auditedList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        planningList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        //closedList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        validatedList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        foreach (var employee in Employee.ByCompany(this.company.Id))
        {
            if ((employee.Active && employee.DisabledDate == null) || this.Auditory.InternalResponsible.Id == employee.Id)
            {
                employesList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    employee.Id,
                    employee.FullName,
                    this.Auditory.InternalResponsible.Id == employee.Id ? " selected=\"selected\"" : string.Empty);
            }

            if (employee.Active || this.Auditory.PlannedBy.Id == employee.Id)
            {
                planningList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    employee.Id,
                    employee.FullName,
                    this.Auditory.PlannedBy.Id == employee.Id ? " selected=\"selected\"" : string.Empty);
            }

            if (employee.Active || this.Auditory.ValidatedBy.Id == employee.Id)
            {
                validatedList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}""{2}>{1}</option>",
                    employee.Id,
                    employee.FullName,
                    this.Auditory.ValidatedBy.Id == employee.Id ? " selected=\"selected\"" : string.Empty);
            }

            if (employee.Active)
            {
                auditedList.AppendFormat(
                    CultureInfo.InvariantCulture,
                    @"<option value=""{0}"">{1}</option>",
                    employee.Id,
                    employee.FullName);
                //closedList.AppendFormat(
                //    CultureInfo.InvariantCulture,
                //    @"<option value=""{0}"">{1}</option>",
                //    employee.Id,
                //    employee.FullName);
            }
        }

        this.LtCmbInternalResponsible.Text      = employesList.ToString();
        this.LtAuditedList.Text                 = auditedList.ToString();
        this.LtAuditoryPlanningResponsible.Text = planningList.ToString();
        //this.LtClosedByList.Text = closedList.ToString();
        this.LtValidatedByList.Text   = validatedList.ToString();
        this.LtWhatHappendByList.Text = validatedList.ToString();


        var auditorList = new StringBuilder();

        auditorList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        foreach (var user in ApplicationUser.CompanyUsers(this.company.Id).Where(us => us.Status != GisoFramework.LogOn.ApplicationLogOn.LogOnResult.None).OrderBy(u => u.UserName))
        {
            auditorList.AppendFormat(
                CultureInfo.InvariantCulture,
                @"<option value=""{0}"">{1}</option>",
                user.Id,
                user.UserName);
        }

        this.LtAuditorList.Text = auditorList.ToString();

        var addressList = new StringBuilder();

        employesList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        foreach (var address in CompanyAddress.GetAddressByCompanyId(this.company))
        {
            addressList.AppendFormat(
                CultureInfo.InvariantCulture,
                @"<option value=""{0}""{2}>{1}</option>",
                address.Id,
                address.Description,
                this.Auditory.CompanyAddressId == address.Id ? " selected=\"selected\"" : string.Empty);
        }

        this.LtCmbAddress.Text = addressList.ToString();

        var providerList = new StringBuilder();

        providerList.AppendFormat(CultureInfo.InvariantCulture, @"<option value=""-1"">{0}</option>", this.Dictionary["Common_SelectOne"]);
        if (this.Auditory.Type == 1 || this.Auditory.Type == 2)
        {
            foreach (var provider in Provider.ByCompany(this.company.Id))
            {
                if (this.auditoryId > 0 || provider.Active)
                {
                    providerList.AppendFormat(
                        CultureInfo.InvariantCulture,
                        @"<option value=""{0}""{2}>{1}</option>",
                        provider.Id,
                        provider.Description,
                        this.Auditory.Provider.Id == provider.Id ? " selected=\"selected\"" : string.Empty);
                }
            }
        }

        this.LtCmbProvider.Text = providerList.ToString();
    }