public NL_Lich_Su_Ban_Than_Chi_Tiet Lay(int Ma_LS_Ban_Than) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NL_Lich_Su_Ban_Than_Lay", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_LS_Ban_Than = new SqlParameter("@Ma_LS_Ban_Than", SqlDbType.Int, 4); pMa_LS_Ban_Than.Value = Ma_LS_Ban_Than; myCommand.Parameters.Add(pMa_LS_Ban_Than); SqlDataAdapter myAdapter = new SqlDataAdapter(); DataSet myDataSet = new DataSet(); myConnection.Open(); myAdapter.SelectCommand = myCommand; myAdapter.Fill(myDataSet, "NL_Lich_Su_Ban_Than_Chi_Tiet"); NL_Lich_Su_Ban_Than_Chi_Tiet myNL_Lich_Su_Ban_Than_Chi_Tiet = new NL_Lich_Su_Ban_Than_Chi_Tiet(); if (myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"] != null) { myNL_Lich_Su_Ban_Than_Chi_Tiet.Ma_LS_Ban_Than = Ma_LS_Ban_Than; myNL_Lich_Su_Ban_Than_Chi_Tiet.Ma_Nhan_Vien = myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Ma_Nhan_Vien"] != DBNull.Value ? (int?)myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Ma_Nhan_Vien"] : (int?)null; myNL_Lich_Su_Ban_Than_Chi_Tiet.Tu_Ngay = myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Tu_Ngay"] != DBNull.Value ? (DateTime?)myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Tu_Ngay"] : (DateTime?)null; myNL_Lich_Su_Ban_Than_Chi_Tiet.Den_Ngay = myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Den_Ngay"] != DBNull.Value ? (DateTime?)myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Den_Ngay"] : (DateTime?)null; myNL_Lich_Su_Ban_Than_Chi_Tiet.Thong_Tin_Lich_Su = myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Thong_Tin_Lich_Su"] != DBNull.Value ? (string)myDataSet.Tables["NL_Lich_Su_Ban_Than_Chi_Tiet"].Rows[0]["Thong_Tin_Lich_Su"] : (string)null; } return(myNL_Lich_Su_Ban_Than_Chi_Tiet); } } }
public void Cap_Nhat(NL_Lich_Su_Ban_Than_Chi_Tiet myNL_Lich_Su_Ban_Than_Chi_Tiet) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NL_Lich_Su_Ban_Than_Cap_Nhat", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_LS_Ban_Than = new SqlParameter("@Ma_LS_Ban_Than", SqlDbType.Int, 4); pMa_LS_Ban_Than.Value = myNL_Lich_Su_Ban_Than_Chi_Tiet.Ma_LS_Ban_Than; myCommand.Parameters.Add(pMa_LS_Ban_Than); SqlParameter pMa_Nhan_Vien = new SqlParameter("@Ma_Nhan_Vien", SqlDbType.Int, 4); pMa_Nhan_Vien.Value = myNL_Lich_Su_Ban_Than_Chi_Tiet.Ma_Nhan_Vien; myCommand.Parameters.Add(pMa_Nhan_Vien); SqlParameter pTu_Ngay = new SqlParameter("@Tu_Ngay", SqlDbType.DateTime, 8); pTu_Ngay.Value = myNL_Lich_Su_Ban_Than_Chi_Tiet.Tu_Ngay; myCommand.Parameters.Add(pTu_Ngay); SqlParameter pDen_Ngay = new SqlParameter("@Den_Ngay", SqlDbType.DateTime, 8); pDen_Ngay.Value = myNL_Lich_Su_Ban_Than_Chi_Tiet.Den_Ngay; myCommand.Parameters.Add(pDen_Ngay); SqlParameter pThong_Tin_Lich_Su = new SqlParameter("@Thong_Tin_Lich_Su", SqlDbType.NText); pThong_Tin_Lich_Su.Value = myNL_Lich_Su_Ban_Than_Chi_Tiet.Thong_Tin_Lich_Su; myCommand.Parameters.Add(pThong_Tin_Lich_Su); myConnection.Open(); myCommand.ExecuteNonQuery(); } } }