private void btCheckin_Click(object sender, EventArgs e) { if (txtMaCN_tkCC.Text == "") { MessageBox.Show("Không có dữ liệu để checkin", "Thông báo"); return; } string day = DateTime.Now.DayOfWeek.ToString(); TimeSpan giotoi = DateTime.Now.TimeOfDay; if (giotoi.Hours <= 11) { bool ditre = false; if (giotoi.Hours > 7) { ditre = true; } GioLamViec glv = new GioLamViec("CALV1", day, giotoi, new TimeSpan(0, 0, 0), ditre, new TimeSpan(0), DateTime.Now, txtMaCN_tkCC.Text, txtMaCN_tkCC.Text); try { cnb.AddGioLamViec(glv); } catch (Exception p) { MessageBox.Show(p.ToString()); } } if (giotoi.Hours >= 11 && giotoi.Hours <= 18) { bool ditre = false; if (giotoi.Hours > 11) { ditre = true; } GioLamViec glv = new GioLamViec("CALV2", day, giotoi, new TimeSpan(0, 0, 0), ditre, new TimeSpan(0), DateTime.Now, txtMaCN_tkCC.Text, txtMaCN_tkCC.Text); try { cnb.AddGioLamViec(glv); } catch (Exception p) { MessageBox.Show(p.ToString()); } } if (giotoi.Hours > 18) { bool ditre = false; if (giotoi.Hours > 18) { ditre = true; } GioLamViec glv = new GioLamViec("CALV3", day, giotoi, new TimeSpan(0, 0, 0), ditre, new TimeSpan(0), DateTime.Now, txtMaCN_tkCC.Text, txtMaCN_tkCC.Text); try { cnb.AddGioLamViec(glv); } catch (Exception p) { MessageBox.Show(p.ToString()); } } try { dgvCheck.DataSource = cnb.ViewGioLamViec("SELECT MaCaLV,Thu,GioToi,GioVe,DiTre,Tong,[Ngay/Thang/Nam],GioLamViec.MaNV,MaGioLamViec,Ho,Ten,Hinh FROM GioLamViec,CongNhan WHERE GioLamViec.MaNV=CongNhan.MaNV AND Thu='" + day + "'").ToList(); cnb.AddLich(txtMaCN_CC.Text, DateTime.Now); } catch (Exception p) { MessageBox.Show(p.ToString()); } }