public NL_DM_Dao_Tao_Chi_Tiet Lay(int Ma_Dao_Tao) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NL_DM_Dao_Tao_Lay", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_Dao_Tao = new SqlParameter("@Ma_Dao_Tao", SqlDbType.Int, 4); pMa_Dao_Tao.Value = Ma_Dao_Tao; myCommand.Parameters.Add(pMa_Dao_Tao); SqlDataAdapter myAdapter = new SqlDataAdapter(); DataSet myDataSet = new DataSet(); myConnection.Open(); myAdapter.SelectCommand = myCommand; myAdapter.Fill(myDataSet, "NL_DM_Dao_Tao_Chi_Tiet"); NL_DM_Dao_Tao_Chi_Tiet myNL_DM_Dao_Tao_Chi_Tiet = new NL_DM_Dao_Tao_Chi_Tiet(); if (myDataSet.Tables["NL_DM_Dao_Tao_Chi_Tiet"] != null) { myNL_DM_Dao_Tao_Chi_Tiet.Ma_Dao_Tao = Ma_Dao_Tao; myNL_DM_Dao_Tao_Chi_Tiet.Ten_Dao_Tao = myDataSet.Tables["NL_DM_Dao_Tao_Chi_Tiet"].Rows[0]["Ten_Dao_Tao"] != DBNull.Value ? (string)myDataSet.Tables["NL_DM_Dao_Tao_Chi_Tiet"].Rows[0]["Ten_Dao_Tao"] : (string)null; myNL_DM_Dao_Tao_Chi_Tiet.STT = myDataSet.Tables["NL_DM_Dao_Tao_Chi_Tiet"].Rows[0]["STT"] != DBNull.Value ? (int?)myDataSet.Tables["NL_DM_Dao_Tao_Chi_Tiet"].Rows[0]["STT"] : (int?)null; } return(myNL_DM_Dao_Tao_Chi_Tiet); } } }
public void Cap_Nhat(NL_DM_Dao_Tao_Chi_Tiet myNL_DM_Dao_Tao_Chi_Tiet) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NL_DM_Dao_Tao_Cap_Nhat", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pMa_Dao_Tao = new SqlParameter("@Ma_Dao_Tao", SqlDbType.Int, 4); pMa_Dao_Tao.Value = myNL_DM_Dao_Tao_Chi_Tiet.Ma_Dao_Tao; myCommand.Parameters.Add(pMa_Dao_Tao); SqlParameter pTen_Dao_Tao = new SqlParameter("@Ten_Dao_Tao", SqlDbType.NVarChar, 200); pTen_Dao_Tao.Value = myNL_DM_Dao_Tao_Chi_Tiet.Ten_Dao_Tao; myCommand.Parameters.Add(pTen_Dao_Tao); SqlParameter pSTT = new SqlParameter("@STT", SqlDbType.Int, 4); pSTT.Value = myNL_DM_Dao_Tao_Chi_Tiet.STT; myCommand.Parameters.Add(pSTT); myConnection.Open(); myCommand.ExecuteNonQuery(); } } }