private void btagregarcuestionario_Click(object sender, EventArgs e) { Forms.AgregarCuestionario oForm = new Forms.AgregarCuestionario(); if (oForm.ShowDialog(this) == DialogResult.OK) { List <Model.Pregunta> oPreguntas = oForm.ListPreguntas; if (oPreguntas.Any()) { Model.Cuestionario oCuestionario = new Model.Cuestionario(); oCuestionario.Pregunta = oPreguntas; oCuestionario.TipoCustionario = 1; oCuestionario.IDUsuario = BusinessLogic.Credenciales.Usuario.NombreUsuario; oCuestionario.Titulo = oForm.Titulo; oCuestionario.FechaFinal = oForm.FechaFinal; oCuestionario.FechaInicio = DateTime.Now; oCuestionario.Descripcion = oForm.Descripcion; ListaCuestionarios.Add(oCuestionario); pnAgregarCuestionario.Controls.Add(new Helpers.PanelAgregarCuestionario(oCuestionario, pnAgregarCuestionario, this).getPanel(oForm.Titulo, Convert.ToString(oPreguntas.Count), Convert.ToString(oPreguntas.Count * 2))); } } }
public PanelAgregarPregunta(Model.Pregunta oPregunta, Panel pnAgregarCuestionario, Forms.AgregarCuestionario agregarCuestionario) { this.oPregunta = oPregunta; this.FormWithList = agregarCuestionario; this.lbPregunta = new MetroLabel(); this.lbPregunta.Location = new System.Drawing.Point(12, 16); this.lbTipoPregunta = new MetroLabel(); this.lbTipoPregunta.Location = new System.Drawing.Point(12, 58); this.btnRemove = new MetroButton(); this.btnRemove.Text = "Remover"; this.btnRemove.Size = this.btnRemove.PreferredSize; this.btnRemove.Location = new System.Drawing.Point(318, 34); this.btnRemove.Click += (e, z) => { agregarCuestionario.ListPreguntas.Remove(oPregunta); pnAgregarCuestionario.Controls.Remove(oPanel); }; this.oPanel = new Panel(); this.oPanel.Dock = System.Windows.Forms.DockStyle.Top; this.oPanel.Height = 105; this.oBar = new MetroPanel(); this.oBar.Dock = System.Windows.Forms.DockStyle.Bottom; this.oBar.Height = 5; this.oBar.UseCustomBackColor = true; this.oBar.BackColor = MetroColors.Blue; this.oPanel.Controls.Add(oBar); this.oPanel.Controls.Add(lbPregunta); this.oPanel.Controls.Add(lbTipoPregunta); this.oPanel.Controls.Add(btnRemove); }