예제 #1
0
        public tarea(int idGrupo, int id, Socket tareas, FlowLayoutPanel flp)
        {
            InitializeComponent();

            this.id = id;
            this.tareas = tareas;
            this.flp = flp;

            DataSourcePOI dsp = new DataSourcePOI();

            DataTable dt = dsp.getTarea(idGrupo);

            pbGamification.Maximum = dt.Rows.Count;

            if (dt != null)
            {
                for (int bc = 0; bc < dt.Rows.Count; bc++)
                {
                    DataTable dtt = dsp.getTareaAlumno(int.Parse(dt.Rows[bc][0].ToString()), id);

                    chkTarea = new CheckBox();
                    chkTarea.Text = dt.Rows[bc][0].ToString() + ", " + dt.Rows[bc][1].ToString();

                    if (dtt != null)
                    {
                        bool stado = bool.Parse(dtt.Rows[0][1].ToString());
                        chkTarea.Checked = stado;

                        if (stado)
                        {
                            pbGamification.Increment(1);
                        }
                    }
                    chkTarea.AutoSize = true;
                    chkTarea.CheckedChanged += new EventHandler(chkTarea_CheckedChanged);
                    flpTarea.Controls.Add(chkTarea);

                }
            }

            this.idGrupo = idGrupo;
        }
예제 #2
0
        private void chkTarea_CheckedChanged(object sender, EventArgs e)
        {
            chkTarea = (CheckBox)sender;
            bool checado = chkTarea.Checked;
            DataSourcePOI dsp = new DataSourcePOI();

            int status = 0;

            string[] texto = chkTarea.Text.Split(',');

            if (checado)
            {
                status = 1;
                pbGamification.Increment(1);
            }
            else {
                pbGamification.Value--;
            }

            DataTable dtt = dsp.getTareaAlumno(int.Parse(texto[0]), id);
            if (dtt != null)
                dsp.actualizarTarea(status, int.Parse(texto[0]));
            else
                dsp.insertarTareaAlumno(status, int.Parse(texto[0]), id);
        }