コード例 #1
0
ファイル: frmTask.cs プロジェクト: deivdks/C-
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            DateTime Date;
            bool     isDate = DateTime.TryParseExact(dtpData.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture,
                                                     DateTimeStyles.None, out Date);

            if (isDate)
            {
                DataTable dt = SqlConn.Read(SqlGenerate.SelecttDataTask(dtpData.Text));
                if (dt.Rows.Count > 0)
                {
                    dtpData.Tag = dt.Rows[0][0];
                    dt          = SqlConn.Read(SqlGenerate.SelectTasks(Convert.ToInt32(dtpData.Tag)));
                    // dgvSenhas.DataSource = dt;
                    foreach (DataRow r in dt.Rows)
                    {
                        int index = dgvTask.Rows.Add();
                        dgvTask.Rows[index].Cells["clnData"].Value      = r["Data"].ToString().Replace("-", "/");
                        dgvTask.Rows[index].Cells["clnTitulo"].Value    = r["Titulo"];
                        dgvTask.Rows[index].Cells["clnHora"].Value      = r["Hora"];
                        dgvTask.Rows[index].Cells["clnDescricao"].Value = r["Descricao"];
                        dgvTask.Rows[index].Cells["clnIdDesc"].Value    = r["id"];
                        dtpData.Tag = r["IdTask"];
                    }
                }
                else
                {
                    dgvTask.Rows.Clear();
                    dtpData.Tag = null;
                }
            }
            else
            {
                dtpData.Tag = null;
                dgvTask.Rows.Clear();
            }
        }