/// <summary> /// lấy thông tin theo dõi của các học sinh trong tháng /// </summary> /// <param name="magv"></param> /// <param name="date"></param> /// <returns></returns> public List <CT_NgayTheoDoi> GetAll_CT_NgayTheoDoi(string magv, DateTime date) { List <CT_NgayTheoDoi> list = new List <CT_NgayTheoDoi>(); using (conn = new SqlConnection(connString)) { if (conn.State != ConnectionState.Open) { conn.Open(); } SqlCommand command = conn.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "getAll_CT_NgayTheoDoi"; command.Parameters.AddWithValue("@MaGiaoVien", magv); command.Parameters.AddWithValue("@NgayTheoDoi", date); SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable dataset = new DataTable(); adapter.Fill(dataset); CT_NgayTheoDoi ct; foreach (DataRow row in dataset.Rows) { ct = new CT_NgayTheoDoi(); ct.MaHocSinh = (string)row["MaHocSinh"]; ct.DDVang = (bool)row["DDVang"]; ct.DDAnSang = (bool)row["DDAnSang"]; ct.DDAnTrua = (bool)row["DDAnTrua"]; list.Add(ct); } } return(list); }
/// <summary> /// Add /// </summary> /// <param name="ct_ngaytheodoi"></param> public void AddCT_NgayTheoDoi(CT_NgayTheoDoi ct_ngaytheodoi) { using (conn ) { if (conn.State != ConnectionState.Open) { conn.Open(); } SqlCommand command = conn.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "InsertUpdateCT_NgayTheoDoi"; command.Parameters.Add("@MaPhieuTheoDoi", SqlDbType.VarChar, 20).Value = ct_ngaytheodoi.MaPhieuTheoDoi; command.Parameters.Add("@MaHocSinh", SqlDbType.VarChar, 20).Value = ct_ngaytheodoi.MaHocSinh; command.Parameters.Add("@DDVang", SqlDbType.Bit).Value = ct_ngaytheodoi.DDVang; command.Parameters.Add("@DDAnSang", SqlDbType.Bit).Value = ct_ngaytheodoi.DDAnSang; command.Parameters.Add("@DDAnTrua", SqlDbType.Bit).Value = ct_ngaytheodoi.DDAnTrua; command.Parameters.Add("@GhiChu", SqlDbType.NVarChar, 100).Value = ct_ngaytheodoi.GhiChu; command.Parameters.Add("@ChiPhi", SqlDbType.Money).Value = ct_ngaytheodoi.ChiPhi; command.Parameters.Add("@Action", SqlDbType.VarChar, 10).Value = "Insert"; try { command.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { command.Dispose(); conn.Dispose(); } } }
/// <summary> /// Hàm lấy danh sách điểm danh cũ /// </summary> /// <param name="maLop"></param> /// <param name="date"></param> public void GetListTheoDoi(string maLop, DateTime date) { if (ListTheoDoi == null) { ListTheoDoi = new ObservableCollection <CT_NgayTheoDoi>(); } else { ListTheoDoi.Clear(); } blo.GetAll_CT_NgayTheoDoi(GiaoVien.MaNhanVien, date).ForEach(p => ListTheoDoi.Add(p)); if (ListTheoDoi.Count() == 0) { CT_NgayTheoDoi ct; foreach (var item in GetListHocSinh(GiaoVien.MaLop)) { ct = new CT_NgayTheoDoi(); ct.MaHocSinh = item.MaHocSinh; ct.DDVang = false; ct.DDAnSang = false; ct.DDAnTrua = false; ListTheoDoi.Add(ct); } } }