public HT_Don_Vi_YT_Chi_Tiet Lay(int Ma_Don_Vi) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("HT_Don_Vi_YT_Lay", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_Don_Vi = new SqlParameter("@Ma_Don_Vi", SqlDbType.Int, 4); pMa_Don_Vi.Value = Ma_Don_Vi; myCommand.Parameters.Add(pMa_Don_Vi); SqlParameter pTen_Don_Vi = new SqlParameter("@Ten_Don_Vi", SqlDbType.NVarChar, 250); pTen_Don_Vi.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pTen_Don_Vi); SqlParameter pTuyen = new SqlParameter("@Tuyen", SqlDbType.Int, 4); pTuyen.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pTuyen); SqlParameter pMa_Tinh = new SqlParameter("@Ma_Tinh", SqlDbType.VarChar, 10); pMa_Tinh.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pMa_Tinh); SqlParameter pMa_Huyen = new SqlParameter("@Ma_Huyen", SqlDbType.VarChar, 10); pMa_Huyen.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pMa_Huyen); SqlParameter pMa_Xa = new SqlParameter("@Ma_Xa", SqlDbType.VarChar, 10); pMa_Xa.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pMa_Xa); SqlParameter pLoai_Hinh = new SqlParameter("@Loai_Hinh", SqlDbType.Int, 4); pLoai_Hinh.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pLoai_Hinh); SqlParameter pThanh_Phan = new SqlParameter("@Thanh_Phan", SqlDbType.Int, 4); pThanh_Phan.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pThanh_Phan); SqlParameter pKB = new SqlParameter("@KB", SqlDbType.Bit, 1); pKB.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pKB); SqlParameter pDP = new SqlParameter("@DP", SqlDbType.Bit, 1); pDP.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pDP); SqlParameter pTB = new SqlParameter("@TB", SqlDbType.Bit, 1); pTB.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pTB); SqlParameter pBC = new SqlParameter("@BC", SqlDbType.Bit, 1); pBC.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pBC); SqlParameter pSK = new SqlParameter("@SK", SqlDbType.Bit, 1); pSK.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pSK); SqlParameter pDB = new SqlParameter("@DB", SqlDbType.Bit, 1); pDB.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pDB); SqlParameter pCP = new SqlParameter("@CP", SqlDbType.Bit, 1); pCP.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pCP); SqlParameter pNL = new SqlParameter("@NL", SqlDbType.Bit, 1); pNL.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pNL); SqlParameter pAT = new SqlParameter("@AT", SqlDbType.Bit, 1); pAT.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pAT); SqlParameter pDV = new SqlParameter("@DV", SqlDbType.Bit, 1); pDV.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pDV); SqlParameter pLoai_Dac_Biet = new SqlParameter("@Loai_Dac_Biet", SqlDbType.Int, 4); pLoai_Dac_Biet.Direction = ParameterDirection.Output; myCommand.Parameters.Add(pLoai_Dac_Biet); myConnection.Open(); myCommand.ExecuteNonQuery(); HT_Don_Vi_YT_Chi_Tiet myHT_Don_Vi_YT_Chi_Tiet = new HT_Don_Vi_YT_Chi_Tiet(); myHT_Don_Vi_YT_Chi_Tiet.Ma_Don_Vi = Ma_Don_Vi; myHT_Don_Vi_YT_Chi_Tiet.Ten_Don_Vi = (string)pTen_Don_Vi.Value; myHT_Don_Vi_YT_Chi_Tiet.Tuyen = (int)pTuyen.Value; myHT_Don_Vi_YT_Chi_Tiet.Ma_Tinh = (string)pMa_Tinh.Value; myHT_Don_Vi_YT_Chi_Tiet.Ma_Huyen = (string)pMa_Huyen.Value; myHT_Don_Vi_YT_Chi_Tiet.Ma_Xa = (string)pMa_Xa.Value; myHT_Don_Vi_YT_Chi_Tiet.Loai_Hinh = (int)pLoai_Hinh.Value; myHT_Don_Vi_YT_Chi_Tiet.Thanh_Phan = (int)pThanh_Phan.Value; myHT_Don_Vi_YT_Chi_Tiet.KB = (bool)pKB.Value; myHT_Don_Vi_YT_Chi_Tiet.DP = (bool)pDP.Value; myHT_Don_Vi_YT_Chi_Tiet.TB = (bool)pTB.Value; myHT_Don_Vi_YT_Chi_Tiet.BC = (bool)pBC.Value; myHT_Don_Vi_YT_Chi_Tiet.SK = (bool)pSK.Value; myHT_Don_Vi_YT_Chi_Tiet.DB = (bool)pDB.Value; myHT_Don_Vi_YT_Chi_Tiet.CP = (bool)pCP.Value; myHT_Don_Vi_YT_Chi_Tiet.NL = (bool)pNL.Value; myHT_Don_Vi_YT_Chi_Tiet.AT = (bool)pAT.Value; myHT_Don_Vi_YT_Chi_Tiet.DV = (bool)pDV.Value; myHT_Don_Vi_YT_Chi_Tiet.Loai_Dac_Biet = (int)pLoai_Dac_Biet.Value; return(myHT_Don_Vi_YT_Chi_Tiet); } } }
public void Cap_Nhat(HT_Don_Vi_YT_Chi_Tiet myHT_Don_Vi_YT_Chi_Tiet) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("HT_Don_Vi_YT_Cap_Nhat", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_Don_Vi = new SqlParameter("@Ma_Don_Vi", SqlDbType.Int, 4); pMa_Don_Vi.Value = myHT_Don_Vi_YT_Chi_Tiet.Ma_Don_Vi; myCommand.Parameters.Add(pMa_Don_Vi); SqlParameter pTen_Don_Vi = new SqlParameter("@Ten_Don_Vi", SqlDbType.NVarChar, 250); pTen_Don_Vi.Value = myHT_Don_Vi_YT_Chi_Tiet.Ten_Don_Vi; myCommand.Parameters.Add(pTen_Don_Vi); SqlParameter pTuyen = new SqlParameter("@Tuyen", SqlDbType.Int, 4); pTuyen.Value = myHT_Don_Vi_YT_Chi_Tiet.Tuyen; myCommand.Parameters.Add(pTuyen); SqlParameter pMa_Tinh = new SqlParameter("@Ma_Tinh", SqlDbType.VarChar, 10); pMa_Tinh.Value = myHT_Don_Vi_YT_Chi_Tiet.Ma_Tinh; myCommand.Parameters.Add(pMa_Tinh); SqlParameter pMa_Huyen = new SqlParameter("@Ma_Huyen", SqlDbType.VarChar, 10); pMa_Huyen.Value = myHT_Don_Vi_YT_Chi_Tiet.Ma_Huyen; myCommand.Parameters.Add(pMa_Huyen); SqlParameter pMa_Xa = new SqlParameter("@Ma_Xa", SqlDbType.VarChar, 10); pMa_Xa.Value = myHT_Don_Vi_YT_Chi_Tiet.Ma_Xa; myCommand.Parameters.Add(pMa_Xa); SqlParameter pLoai_Hinh = new SqlParameter("@Loai_Hinh", SqlDbType.Int, 4); pLoai_Hinh.Value = myHT_Don_Vi_YT_Chi_Tiet.Loai_Hinh; myCommand.Parameters.Add(pLoai_Hinh); SqlParameter pThanh_Phan = new SqlParameter("@Thanh_Phan", SqlDbType.Int, 4); pThanh_Phan.Value = myHT_Don_Vi_YT_Chi_Tiet.Thanh_Phan; myCommand.Parameters.Add(pThanh_Phan); SqlParameter pKB = new SqlParameter("@KB", SqlDbType.Bit, 1); pKB.Value = myHT_Don_Vi_YT_Chi_Tiet.KB; myCommand.Parameters.Add(pKB); SqlParameter pDP = new SqlParameter("@DP", SqlDbType.Bit, 1); pDP.Value = myHT_Don_Vi_YT_Chi_Tiet.DP; myCommand.Parameters.Add(pDP); SqlParameter pTB = new SqlParameter("@TB", SqlDbType.Bit, 1); pTB.Value = myHT_Don_Vi_YT_Chi_Tiet.TB; myCommand.Parameters.Add(pTB); SqlParameter pBC = new SqlParameter("@BC", SqlDbType.Bit, 1); pBC.Value = myHT_Don_Vi_YT_Chi_Tiet.BC; myCommand.Parameters.Add(pBC); SqlParameter pSK = new SqlParameter("@SK", SqlDbType.Bit, 1); pSK.Value = myHT_Don_Vi_YT_Chi_Tiet.SK; myCommand.Parameters.Add(pSK); SqlParameter pDB = new SqlParameter("@DB", SqlDbType.Bit, 1); pDB.Value = myHT_Don_Vi_YT_Chi_Tiet.DB; myCommand.Parameters.Add(pDB); SqlParameter pCP = new SqlParameter("@CP", SqlDbType.Bit, 1); pCP.Value = myHT_Don_Vi_YT_Chi_Tiet.CP; myCommand.Parameters.Add(pCP); SqlParameter pNL = new SqlParameter("@NL", SqlDbType.Bit, 1); pNL.Value = myHT_Don_Vi_YT_Chi_Tiet.NL; myCommand.Parameters.Add(pNL); SqlParameter pAT = new SqlParameter("@AT", SqlDbType.Bit, 1); pAT.Value = myHT_Don_Vi_YT_Chi_Tiet.AT; myCommand.Parameters.Add(pAT); SqlParameter pDV = new SqlParameter("@DV", SqlDbType.Bit, 1); pDV.Value = myHT_Don_Vi_YT_Chi_Tiet.DV; myCommand.Parameters.Add(pDV); SqlParameter pLoai_Dac_Biet = new SqlParameter("@Loai_Dac_Biet", SqlDbType.Int, 4); pLoai_Dac_Biet.Value = myHT_Don_Vi_YT_Chi_Tiet.Loai_Dac_Biet; myCommand.Parameters.Add(pLoai_Dac_Biet); myConnection.Open(); myCommand.ExecuteNonQuery(); } } }