示例#1
0
        public int DevolverAlineacion(Cuestionario c)
        {
            int nLength = 0;
            int nAlin = 0;

            for (int i = 0; i < c.Preguntas.Count; i++)
            {
                Pregunta p = new Pregunta();
                p = c.Preguntas[i];

                if (p.Descripcion.ToString().Trim().Replace(" ", "-").Length > nLength)
                {
                    nLength = p.Descripcion.ToString().Trim().Replace(" ", "-").Length;
                }
            }
            nAlin = (nLength * 6) - (nLength/2);
            return nAlin;
        }
示例#2
0
        public void CargarCuestionarios()
        {
            gestorCuestionario = new GestorCuestionario();
            listaCuestionario = gestorCuestionario.buscar(false, "", "");
            int nTop = 10;
            int nLeft = 0;
             for (int i = 0; i < listaCuestionario.Count; i++)
            {
                nTop = 10;
                nLeft = 0;
                cuestionario = new Cuestionario();
                cuestionario = listaCuestionario[i];

                TabPage pagina = new TabPage(cuestionario.Descripcion);
                pagina.AutoScroll = true;
                listaPregunta = new List<Pregunta>();
                listaPregunta = cuestionario.Preguntas;
                nLeft = DevolverAlineacion(cuestionario);

                listaPregunta=OrdenarPreguntas(listaPregunta);

                for (int j = 0; j < listaPregunta.Count; j++)
                {
                    pregunta = new Pregunta();
                    pregunta = listaPregunta[j];
                    if (pregunta.TipoPregunta.Codigo == "RB")//tipo radio button
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion.ToString();
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width=nLeft-5;
                        pagina.Controls.Add(label);
                        System.Windows.Forms.GroupBox gb = new GroupBox();
                        gb.Text = "";
                        gb.Top = nTop - 9;
                        gb.Left = nLeft;
                        gb.Height = 28;
                        listaOpcion = new List<Opcion>();
                        listaOpcion = pregunta.Opciones;
                        int nWidth = 0;
                        int ancho = 0;
                        for (int h = 0; h < listaOpcion.Count; h++)
                        {
                            System.Windows.Forms.RadioButton rb = new RadioButton();
                            rb.Text = listaOpcion[h].Descripcion;
                            rb.Top = 7;
                            rb.Left = 13;
                            rb.Height = 20;
                            rb.Width = rb.Text.Length * 25;
                            if (h > 0)
                            {
                                rb.Left = 15 + nWidth * 5;
                            }
                            if (listaOpcion[h].Id == pregunta.Opcion.Id)
                            { rb.Checked = true; }
                            gb.Controls.Add(rb);
                            nWidth = rb.Text.Length * 10;
                            ancho = ancho + nWidth;
                        }
                        gb.Width = ancho * 5;
                        pagina.Controls.Add(gb);
                        nTop = nTop + label.Height + 8;
                    }
                    if (pregunta.TipoPregunta.Codigo == "CMB")//tipo combo box
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = nLeft-5;
                        pagina.Controls.Add(label);
                        System.Windows.Forms.ComboBox cmb = new ComboBox();
                        for (int h = 0; h < listaOpcion.Count; h++)
                        {
                            Opcion op = new Opcion();
                            op = listaOpcion[h];
                            cmb.Items.Add(op);
                        }
                        cmb.DisplayMember = "Descripcion";
                        cmb.Top = nTop - 2;
                        cmb.Left = nLeft;
                        pagina.Controls.Add(cmb);
                        nTop = nTop + label.Height + 8;
                    }
                    if (pregunta.TipoPregunta.Codigo == "NRO")//tipo valor numerico
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = nLeft -5;
                        pagina.Controls.Add(label);
                        System.Windows.Forms.MaskedTextBox txt = new MaskedTextBox();
                        txt.Top = nTop - 4;
                        txt.Left = nLeft;
                        txt.Mask = "999";
                        pagina.Controls.Add(txt);
                        nTop = nTop + label.Height + 8;
                    }
                    if (pregunta.TipoPregunta.Codigo == "GRP")//tipo Encabezado
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = pregunta.Descripcion.Length * 16;
                        pagina.Controls.Add(label);
                        System.Drawing.Font fuente = new Font(System.Drawing.FontFamily.GenericSansSerif, 14, System.Drawing.FontStyle.Bold);
                        label.Font = fuente;
                        nTop = nTop + label.Height + 13;
                    }
                    if (pregunta.TipoPregunta.Codigo == "FEC")//tipo Fecha
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = nLeft - 5;
                        pagina.Controls.Add(label);
                        System.Windows.Forms.DateTimePicker dp = new DateTimePicker();
                        dp.Top = nTop - 5;
                        dp.Left = nLeft;
                        dp.Format = DateTimePickerFormat.Short;
                        dp.Width = DateTimePickerFormat.Short.ToString().Length * 20;
                        pagina.Controls.Add(dp);
                        nTop = nTop + label.Height + 8;

                    }
                    if (pregunta.TipoPregunta.Codigo == "TXT")//text box
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = nLeft -5;
                        pagina.Controls.Add(label);
                        System.Windows.Forms.TextBox txt = new TextBox();
                        txt.Top = nTop - 4;
                        txt.Left = nLeft;
                        pagina.Controls.Add(txt);
                        nTop = nTop + label.Height + 8;
                    }
                    if (pregunta.TipoPregunta.Codigo == "CB")//check box
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = nLeft - 5;
                        pagina.Controls.Add(label);
                        listaOpcion = new List<Opcion>();
                        listaOpcion = pregunta.Opciones;
                        int nWidth = 0;
                        for (int h = 0; h < listaOpcion.Count; h++)
                        {
                            System.Windows.Forms.CheckBox chb = new CheckBox();
                            chb.Text = listaOpcion[h].Descripcion;
                            chb.Top = nTop - 4;
                            chb.Left = nLeft;
                            chb.Width = chb.Text.Length * 25;
                            if (h > 0)
                            {
                                chb.Left = nLeft + 15 + nWidth * 5;
                            }
                            pagina.Controls.Add(chb);
                            nWidth = chb.Text.Length * 10;
                        }

                        nTop = nTop + label.Height + 8;
                    }
                    if (pregunta.TipoPregunta.Codigo == "SM")//check box list
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = nLeft - 5;
                        pagina.Controls.Add(label);
                        System.Windows.Forms.CheckedListBox chlb = new CheckedListBox();
                        chlb.Top = nTop - 4;
                        chlb.Left = nLeft;
                        listaOpcion = new List<Opcion>();
                        listaOpcion = pregunta.Opciones;
                        for (int h = 0; h < listaOpcion.Count; h++)
                        {
                            chlb.Items.Add(listaOpcion[h].Descripcion);
                        }
                        pagina.Controls.Add(chlb);
                        nTop = nTop + label.Height + 8;
                    }
                    if (pregunta.TipoPregunta.Codigo == "ACL")//Aclaracion/nota
                    {
                        System.Windows.Forms.Label label = new Label();
                        label.Text = pregunta.Descripcion;
                        label.Top = nTop;
                        label.Left = 4;
                        label.Width = 50;
                        label.AutoSize = true;
                        pagina.Controls.Add(label);
                        nTop = nTop + label.Height + 8;
                    }
                }
                tabControlVisita.Controls.Add(pagina);
            }
        }