private void button1_Click(object sender, EventArgs e) { AttendanceClass ac = new AttendanceClass(); String[] time = { "08:15", "08:25", "08:55", "09:15", "08:00", "08:22", "09:05", "08:05", "09:20", "08:35" }; String[] date = { "9-10-2019", "11-10-2019", "15-10-2019", "12-11-2019", "12-10-2019", "10-09-2019", "27-10-2019", "25-11-2019", "5-11-2019", "12-12-2019" }; int[] id = { 1, 2, 1, 4, 5, 3, 7, 4, 2, 1 }; for (int x = 0; x < 10; x++) { ac.Insert(id[x], date[x], time[x]); } }
private void BtnInsert_Click(object sender, EventArgs e) { if (txtEmployeeId.Text == string.Empty) { MessageBox.Show("Plaese fill the empty fields!"); } else if (txtEmployeeId.Text == string.Empty) { MessageBox.Show("Please enter an Employee Id!"); } /* else if(txtArrivedTime.Text == string.Empty) * { * MessageBox.Show("Plaese enter the arrived time"); * }*/ else if (!int.TryParse(txtEmployeeId.Text, out Id)) { MessageBox.Show("Employee ID is invaid"); } else { a.EmployeeId = Int32.Parse(txtEmployeeId.Text); a.Date = dateTimePicker1.Text; // lblInTime.Text = DateTime.Now.ToString("HH:mm"); a.ArrivedTime = lblInTime.Text; //a.ArrivedTime = lblInTime.Text; // a.ArrivedTime = txtArrivedTime.Text; // a.LeftTime = int.Parse(txtLeaftTime.Text); bool success = a.Insert(a); if (success == true) { MessageBox.Show("Successfully inserted"); } else { MessageBox.Show("Cannot insert"); } DataTable dt = a.Select(); dataGridView.DataSource = dt; } }