public NL_To_Nhom_Chi_Tiet Lay(int Ma_To_Nhom) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NL_To_Nhom_Lay", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_To_Nhom = new SqlParameter("@Ma_To_Nhom", SqlDbType.Int, 4); pMa_To_Nhom.Value = Ma_To_Nhom; myCommand.Parameters.Add(pMa_To_Nhom); SqlDataAdapter myAdapter = new SqlDataAdapter(); DataSet myDataSet = new DataSet(); myConnection.Open(); myAdapter.SelectCommand = myCommand; myAdapter.Fill(myDataSet, "NL_To_Nhom_Chi_Tiet"); NL_To_Nhom_Chi_Tiet myNL_To_Nhom_Chi_Tiet = new NL_To_Nhom_Chi_Tiet(); if (myDataSet.Tables["NL_To_Nhom_Chi_Tiet"] != null) { myNL_To_Nhom_Chi_Tiet.Ma_To_Nhom = Ma_To_Nhom; myNL_To_Nhom_Chi_Tiet.Ma_Nhan_Vien = myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Ma_Nhan_Vien"] != DBNull.Value ? (int?)myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Ma_Nhan_Vien"] : (int?)null; myNL_To_Nhom_Chi_Tiet.Tu_Ngay = myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Tu_Ngay"] != DBNull.Value ? (DateTime?)myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Tu_Ngay"] : (DateTime?)null; myNL_To_Nhom_Chi_Tiet.Den_Ngay = myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Den_Ngay"] != DBNull.Value ? (DateTime?)myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Den_Ngay"] : (DateTime?)null; myNL_To_Nhom_Chi_Tiet.Ten_Nhom = myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Ten_Nhom"] != DBNull.Value ? (string)myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Ten_Nhom"] : (string)null; myNL_To_Nhom_Chi_Tiet.Nhiem_Vu = myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Nhiem_Vu"] != DBNull.Value ? (string)myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Nhiem_Vu"] : (string)null; myNL_To_Nhom_Chi_Tiet.Biet_Phai = myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Biet_Phai"] != DBNull.Value ? (bool?)myDataSet.Tables["NL_To_Nhom_Chi_Tiet"].Rows[0]["Biet_Phai"] : (bool?)null; } return(myNL_To_Nhom_Chi_Tiet); } } }
public void Cap_Nhat(NL_To_Nhom_Chi_Tiet myNL_To_Nhom_Chi_Tiet) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NL_To_Nhom_Cap_Nhat", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_To_Nhom = new SqlParameter("@Ma_To_Nhom", SqlDbType.Int, 4); pMa_To_Nhom.Value = myNL_To_Nhom_Chi_Tiet.Ma_To_Nhom; myCommand.Parameters.Add(pMa_To_Nhom); SqlParameter pMa_Nhan_Vien = new SqlParameter("@Ma_Nhan_Vien", SqlDbType.Int, 4); pMa_Nhan_Vien.Value = myNL_To_Nhom_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_To_Nhom_Chi_Tiet.Tu_Ngay; myCommand.Parameters.Add(pTu_Ngay); SqlParameter pDen_Ngay = new SqlParameter("@Den_Ngay", SqlDbType.DateTime, 8); pDen_Ngay.Value = myNL_To_Nhom_Chi_Tiet.Den_Ngay; myCommand.Parameters.Add(pDen_Ngay); SqlParameter pTen_Nhom = new SqlParameter("@Ten_Nhom", SqlDbType.NVarChar, 500); pTen_Nhom.Value = myNL_To_Nhom_Chi_Tiet.Ten_Nhom; myCommand.Parameters.Add(pTen_Nhom); SqlParameter pNhiem_Vu = new SqlParameter("@Nhiem_Vu", SqlDbType.NVarChar, 500); pNhiem_Vu.Value = myNL_To_Nhom_Chi_Tiet.Nhiem_Vu; myCommand.Parameters.Add(pNhiem_Vu); SqlParameter pBiet_Phai = new SqlParameter("@Biet_Phai", SqlDbType.Bit, 1); pBiet_Phai.Value = myNL_To_Nhom_Chi_Tiet.Biet_Phai; myCommand.Parameters.Add(pBiet_Phai); myConnection.Open(); myCommand.ExecuteNonQuery(); } } }